diff --git a/config/dedup.us.yaml b/config/dedup.us.yaml index e06a715bf0..ac338cbd6b 100644 --- a/config/dedup.us.yaml +++ b/config/dedup.us.yaml @@ -13830,3 +13830,255 @@ groups: func: DEFINE_func_801EF864 vram: 0x801EF864 binaries: [md_SC03_073, md_SC03_074, md_SC03_075, md_SC03_078] + - id: E_func_8017E518 + tier: h_exact + hash: 7678540574197b420f17571673856a74783eb9d5 + source: src/shared/engine_core.h + func: DEFINE_func_8017E518 + vram: 0x8017E518 + binaries: [ov_SC02_011, ov_SC07_010] + - id: E_func_8012A018 + tier: h_exact + hash: 6d717730b63623e5afd71638433f7f71ea7da104 + source: src/shared/engine_core.h + func: DEFINE_func_8012A018 + vram: 0x8012A018 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_80131CA8 + tier: h_exact + hash: 2c9ae3cd2149c1ccaf077a92ef3b1560cfb45892 + source: src/shared/engine_core.h + func: DEFINE_func_80131CA8 + vram: 0x80131CA8 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_80172C50 + tier: h_exact + hash: d50cc5103cf668a20a8885ea3fa49d385921f0c6 + source: src/shared/engine_core.h + func: DEFINE_func_80172C50 + vram: 0x80172C50 + binaries: [ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_8016BF50 + tier: h_exact + hash: 1c5bc11f816e9ed71badae45bfb8bee66eef7a77 + source: src/shared/engine_core.h + func: DEFINE_func_8016BF50 + vram: 0x8016BF50 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_8015C030 + tier: h_exact + hash: 6ff3d32fd8d88565efbc3cd350abe6d8b19a44da + source: src/shared/engine_core.h + func: DEFINE_func_8015C030 + vram: 0x8015C030 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_80162CCC + tier: h_exact + hash: 14311349434d4c88386aa81d7b1fb2496c058406 + source: src/shared/engine_core.h + func: DEFINE_func_80162CCC + vram: 0x80162CCC + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011] + - id: E_func_8016191C + tier: h_exact + hash: 64d215dba6403d2f9dac9cddc1cad36b86fd4183 + source: src/shared/engine_core.h + func: DEFINE_func_8016191C + vram: 0x8016191C + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_801733FC + tier: h_exact + hash: 3e4f009550dab611ed9f7647fbe77751180392d1 + source: src/shared/engine_core.h + func: DEFINE_func_801733FC + vram: 0x801733FC + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_80137614 + tier: h_exact + hash: d0c883314e834129318911cc73151f97be0ea54b + source: src/shared/engine_core.h + func: DEFINE_func_80137614 + vram: 0x80137614 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_8016F0E4 + tier: h_exact + hash: 72d01994cf9fe87931707bdab7d8d1c31e183700 + source: src/shared/engine_core.h + func: DEFINE_func_8016F0E4 + vram: 0x8016F0E4 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_8013C08C + tier: h_exact + hash: f769ff8982ba0db385e1f6f98efdcf55322c569e + source: src/shared/engine_core.h + func: DEFINE_func_8013C08C + vram: 0x8013C08C + binaries: [ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011] + - id: E_func_80131CF4 + tier: h_exact + hash: 9d2db9ce3c152f0a68111194fc0669f742d061d4 + source: src/shared/engine_core.h + func: DEFINE_func_80131CF4 + vram: 0x80131CF4 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_8016706C + tier: h_exact + hash: e0963a4b81c4bccd04dadc1fdf04046f866a7748 + source: src/shared/engine_core.h + func: DEFINE_func_8016706C + vram: 0x8016706C + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009] + - id: E_func_801708B0 + tier: h_exact + hash: 07865805ddd66d8a8db6ba5c550d2bcc75f95b97 + source: src/shared/engine_core.h + func: DEFINE_func_801708B0 + vram: 0x801708B0 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_80170CF0 + tier: h_exact + hash: 763e8b3b2726cbf5a7985d465ecca9a877a244f5 + source: src/shared/engine_core.h + func: DEFINE_func_80170CF0 + vram: 0x80170CF0 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_8012EFB8 + tier: h_exact + hash: 26e46daf805399cb7c4f5bfaff10b4d364d6835b + source: src/shared/engine_core.h + func: DEFINE_func_8012EFB8 + vram: 0x8012EFB8 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_801495C4 + tier: h_exact + hash: 53d8b268573d0fb9dce75964929209e5f738b8f3 + source: src/shared/engine_core.h + func: DEFINE_func_801495C4 + vram: 0x801495C4 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_8012F40C + tier: h_exact + hash: d63a10fab8ca1851076def4eecccdcfb9ac156aa + source: src/shared/engine_core.h + func: DEFINE_func_8012F40C + vram: 0x8012F40C + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_80131A34 + tier: h_exact + hash: d5151bada3bcee210206e34a48b631fc61433b7f + source: src/shared/engine_core.h + func: DEFINE_func_80131A34 + vram: 0x80131A34 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_801778A8 + tier: h_exact + hash: 3ca961dede12e7acfa59d3d9e47ec477ba4dda97 + source: src/shared/engine_core.h + func: DEFINE_func_801778A8 + vram: 0x801778A8 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_80161374 + tier: h_exact + hash: 8868d139b43bac84082f12d5da53795ffec64c87 + source: src/shared/engine_core.h + func: DEFINE_func_80161374 + vram: 0x80161374 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_8014C4AC + tier: h_exact + hash: 41904b3e5c3fb386b9abeb944bb95f9729460efe + source: src/shared/engine_core.h + func: DEFINE_func_8014C4AC + vram: 0x8014C4AC + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_801376E8 + tier: h_exact + hash: 7529ad8f17b78ef2f57770ea07d5e53fbb501b5b + source: src/shared/engine_core.h + func: DEFINE_func_801376E8 + vram: 0x801376E8 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_80175820 + tier: h_exact + hash: 8d29c3b272b414ce4a16fae1dfff7fdec130028c + source: src/shared/engine_core.h + func: DEFINE_func_80175820 + vram: 0x80175820 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_801759D8 + tier: h_exact + hash: 20aa0ffd5a2dbbda99c0060aefe05cefbc21c2d0 + source: src/shared/engine_core.h + func: DEFINE_func_801759D8 + vram: 0x801759D8 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_8012B77C + tier: h_exact + hash: 5c649b513794ad31e52f8bf64a2f244ecc1f0dac + source: src/shared/engine_core.h + func: DEFINE_func_8012B77C + vram: 0x8012B77C + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_8014E5B4 + tier: h_exact + hash: 4ed201dcd22f5d9c69f4a9e86dfec8d892b7202c + source: src/shared/engine_core.h + func: DEFINE_func_8014E5B4 + vram: 0x8014E5B4 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_80173A60 + tier: h_exact + hash: d62e1dd55726d7830038a5bfd5286d94ad9d7ca4 + source: src/shared/engine_core.h + func: DEFINE_func_80173A60 + vram: 0x80173A60 + binaries: [ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_80138DE0 + tier: h_exact + hash: b21f8e9cd7866d40b04e85a303606c20e04fc55b + source: src/shared/engine_core.h + func: DEFINE_func_80138DE0 + vram: 0x80138DE0 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_8014A738 + tier: h_exact + hash: b51a4f8cea147ea8fd921c848e208ee96c7b9e3c + source: src/shared/engine_core.h + func: DEFINE_func_8014A738 + vram: 0x8014A738 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_80133298 + tier: h_exact + hash: dd5916cc5c133cf00f62c09e196a57f4b4c5c504 + source: src/shared/engine_core.h + func: DEFINE_func_80133298 + vram: 0x80133298 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_8014D610 + tier: h_exact + hash: 9af217fd231ac9b8498bb67b49d30e6e199a8026 + source: src/shared/engine_core.h + func: DEFINE_func_8014D610 + vram: 0x8014D610 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_80163534 + tier: h_exact + hash: dcf9ec7e921a8686c6cac163cb89d69a0cc91727 + source: src/shared/engine_core.h + func: DEFINE_func_80163534 + vram: 0x80163534 + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_8012A1BC + tier: h_exact + hash: 497f8cc90696d8db106b7c7ed65f87ccf5854d1d + source: src/shared/engine_core.h + func: DEFINE_func_8012A1BC + vram: 0x8012A1BC + binaries: [ov_SC01_077, ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_000, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_018, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] + - id: E_func_801749C8 + tier: h_exact + hash: 7e04ee1875d81cff86833b19a385e347632ac616 + source: src/shared/engine_core.h + func: DEFINE_func_801749C8 + vram: 0x801749C8 + binaries: [ov_SC01_005, ov_SC01_006, ov_SC03_001, ov_SC01_001, ov_SC02_000, ov_SC02_003, ov_SC03_002, ov_SC03_006, ov_SC04_000, ov_SC04_018, ov_SC04_019, ov_SC05_000, ov_SC06_000, ov_SC07_000, ov_SC01_004, ov_SC01_008, ov_SC01_009, ov_SC01_074, ov_SC01_080, ov_SC01_084, ov_SC02_004, ov_SC02_005, ov_SC02_011, ov_SC02_015, ov_SC02_016, ov_SC02_017, ov_SC02_021, ov_SC02_026, ov_SC02_027, ov_SC02_028, ov_SC02_031, ov_SC02_035, ov_SC02_039, ov_SC02_041, ov_SC03_003, ov_SC03_007, ov_SC03_010, ov_SC03_011, ov_SC03_012, ov_SC03_013, ov_SC03_014, ov_SC03_015, ov_SC03_023, ov_SC03_024, ov_SC03_028, ov_SC03_029, ov_SC03_030, ov_SC03_031, ov_SC03_089, ov_SC03_090, ov_SC03_091, ov_SC03_092, ov_SC03_093, ov_SC03_094, ov_SC03_095, ov_SC03_096, ov_SC03_097, ov_SC03_098, ov_SC03_099, ov_SC03_100, ov_SC03_101, ov_SC03_102, ov_SC03_103, ov_SC03_104, ov_SC03_105, ov_SC03_108, ov_SC03_109, ov_SC03_110, ov_SC03_111, ov_SC03_112, ov_SC03_113, ov_SC03_114, ov_SC03_115, ov_SC03_116, ov_SC03_117, ov_SC03_118, ov_SC03_119, ov_SC03_121, ov_SC03_124, ov_SC03_125, ov_SC03_126, ov_SC04_002, ov_SC04_003, ov_SC04_004, ov_SC04_005, ov_SC04_006, ov_SC04_007, ov_SC04_008, ov_SC04_009, ov_SC04_010, ov_SC04_011, ov_SC04_012, ov_SC04_015, ov_SC04_016, ov_SC04_020, ov_SC04_021, ov_SC05_001, ov_SC05_002, ov_SC05_003, ov_SC05_004, ov_SC05_005, ov_SC05_006, ov_SC05_007, ov_SC05_008, ov_SC05_009, ov_SC05_010, ov_SC05_011, ov_SC05_017, ov_SC05_018, ov_SC05_019, ov_SC06_006, ov_SC06_008, ov_SC06_010, ov_SC06_011, ov_SC06_013, ov_SC06_014, ov_SC06_015, ov_SC06_016, ov_SC06_020, ov_SC06_022, ov_SC06_024, ov_SC06_025, ov_SC06_027, ov_SC06_029, ov_SC06_030, ov_SC06_032, ov_SC06_033, ov_SC07_001, ov_SC07_002, ov_SC07_008, ov_SC07_009, ov_SC07_006, ov_SC07_007, ov_SC07_010, ov_SC07_011, ov_MAIN_012, ov_SC02_037, ov_SC03_107] diff --git a/src/ov_MAIN_012/ov_MAIN_012.c b/src/ov_MAIN_012/ov_MAIN_012.c index e2e44ee2e3..98d48b3e07 100644 --- a/src/ov_MAIN_012/ov_MAIN_012.c +++ b/src/ov_MAIN_012/ov_MAIN_012.c @@ -730,14 +730,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129cf8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129ff4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012a048 (src/shared) */ @@ -769,40 +762,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012a110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012a2f4 (src/shared) */ @@ -1124,33 +1084,7 @@ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012b744 (src/shared) */ * `struct{s16 lo,hi;}` would be BLKmode and spill to the stack instead). */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); -extern s32 func_8004787C(s32 a0); - - - -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012b864 (src/shared) */ @@ -1897,23 +1831,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012ef70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ DEFINE_func_8012F038() /* dedup: shared engine-core @0x8012f038 (src/shared) */ @@ -1946,29 +1864,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012f374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012f49c (src/shared) */ diff --git a/src/ov_MAIN_012/ov_MAIN_012_jr_80131340.c b/src/ov_MAIN_012/ov_MAIN_012_jr_80131340.c index 2196ed6f37..59de3d0d9a 100644 --- a/src/ov_MAIN_012/ov_MAIN_012_jr_80131340.c +++ b/src/ov_MAIN_012/ov_MAIN_012_jr_80131340.c @@ -870,25 +870,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319e0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131ac8 (src/shared) */ @@ -999,15 +981,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ typedef struct { s8 c[8]; } Blk8_80131CF4; @@ -1040,37 +1014,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131d68 (src/shared) */ @@ -1570,35 +1514,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339c (src/shared) */ diff --git a/src/ov_MAIN_012/ov_MAIN_012_jr_80135EB0.c b/src/ov_MAIN_012/ov_MAIN_012_jr_80135EB0.c index 3fdcee77a0..8fb88fe051 100644 --- a/src/ov_MAIN_012/ov_MAIN_012_jr_80135EB0.c +++ b/src/ov_MAIN_012/ov_MAIN_012_jr_80135EB0.c @@ -1232,17 +1232,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767c (src/shared) */ @@ -1288,32 +1278,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377b4 (src/shared) */ diff --git a/src/ov_MAIN_012/ov_MAIN_012_jr_801380E0.c b/src/ov_MAIN_012/ov_MAIN_012_jr_801380E0.c index 6a2354eff9..7e78ed87f9 100644 --- a/src/ov_MAIN_012/ov_MAIN_012_jr_801380E0.c +++ b/src/ov_MAIN_012/ov_MAIN_012_jr_801380E0.c @@ -1125,43 +1125,7 @@ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138db8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ed0 (src/shared) */ diff --git a/src/ov_MAIN_012/ov_MAIN_012_jr_8013F350.c b/src/ov_MAIN_012/ov_MAIN_012_jr_8013F350.c index 99da62b1c5..0f391aa989 100644 --- a/src/ov_MAIN_012/ov_MAIN_012_jr_8013F350.c +++ b/src/ov_MAIN_012/ov_MAIN_012_jr_8013F350.c @@ -4418,52 +4418,7 @@ void func_80149584(s32 a0, s32 a1, s32 a2) } -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ DEFINE_func_8014964C() /* dedup: shared engine-core @0x8014964c (src/shared) */ @@ -4685,50 +4640,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014a71c (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014a830 (src/shared) */ @@ -4970,38 +4882,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014c43c (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U *)(a0 + 0x7C) = *(V4U *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ DEFINE_func_8014C568() /* dedup: shared engine-core @0x8014c568 (src/shared) */ @@ -5233,38 +5114,7 @@ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014d4c0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -5788,41 +5638,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_MAIN_012/ov_MAIN_012_jr_8015A3C8.c b/src/ov_MAIN_012/ov_MAIN_012_jr_8015A3C8.c index 225a4dc2ec..5130878be2 100644 --- a/src/ov_MAIN_012/ov_MAIN_012_jr_8015A3C8.c +++ b/src/ov_MAIN_012/ov_MAIN_012_jr_8015A3C8.c @@ -3102,20 +3102,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015c08c (src/shared) */ @@ -5406,31 +5393,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -5463,61 +5426,7 @@ DEFINE_func_80161774() /* dedup: shared engine-core @0x80161774 (src/shared) */ DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); -extern s32 func_8016163C(s32 a0, u32 a1); -extern s32 func_80161774(int a0, u32 a1); -extern s32 func_80161888(s32 a0, u32 a1); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197c (src/shared) */ @@ -6236,51 +6145,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ diff --git a/src/ov_MAIN_012/ov_MAIN_012_jr_8016AE5C.c b/src/ov_MAIN_012/ov_MAIN_012_jr_8016AE5C.c index 5d24099a6b..c77cea08de 100644 --- a/src/ov_MAIN_012/ov_MAIN_012_jr_8016AE5C.c +++ b/src/ov_MAIN_012/ov_MAIN_012_jr_8016AE5C.c @@ -3349,21 +3349,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016bf34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -4656,37 +4642,7 @@ void func_8016F0AC(void) { * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016f14c (src/shared) */ @@ -5156,26 +5112,7 @@ DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084c (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -5242,38 +5179,7 @@ DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170cb0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_MAIN_012/ov_MAIN_012_jr_80171B4C.c b/src/ov_MAIN_012/ov_MAIN_012_jr_80171B4C.c index 74526038af..57115755dc 100644 --- a/src/ov_MAIN_012/ov_MAIN_012_jr_80171B4C.c +++ b/src/ov_MAIN_012/ov_MAIN_012_jr_80171B4C.c @@ -3412,14 +3412,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172bc8 (src/shared) */ void func_80172C48(void) { } -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -3546,18 +3539,7 @@ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733cc (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ @@ -3660,41 +3642,7 @@ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173a28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) -{ - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -3875,49 +3823,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749a8 (src/shared) */ // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - - extern u16 D_80126B5E; - extern u16 D_80126B62; - extern u16 D_80126B66; - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174b6c (src/shared) */ @@ -4127,53 +4033,7 @@ DEFINE_func_801757A0() /* dedup: shared engine-core @0x801757a0 (src/shared) */ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757e0 (src/shared) */ -extern s32 func_801758FC(void); - -/* func_80175820 — twin of the byte-matched func_801759D8 / func_801758FC in this same TU - * (ov_SC01_077_jr_801734BC). Same three-part body, different slot: - * part 1 tag word = ptr[2] (0x8 vs 0x4 / 0xC) - * part 2 head ptr = D_8011F7A8+0x18 (== D_8011F7C0) - * part 3 tail ptr = D_8011F7A8+0x20 (== D_8011F7C8) - * The two __asm__ memory fences are what keep the three parts from CSE-ing their - * base addresses together (parts 1/2 stay absolute lui/%lo + idx*4; part 3 keeps the - * shared `la $v1,D_8011F7A8` + 0x18/0x20 displacements). - */ - - /* size 0x14 */ - /* size 0x0C */ - -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820 D_800AE7BC[]; - extern S_AF634_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758fc (src/shared) */ @@ -4185,44 +4045,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758fc (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -4995,41 +4818,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777bc (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC01_000/ov_SC01_000.c b/src/ov_SC01_000/ov_SC01_000.c index c877a095a4..a5bc58d400 100644 --- a/src/ov_SC01_000/ov_SC01_000.c +++ b/src/ov_SC01_000/ov_SC01_000.c @@ -675,14 +675,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -708,40 +701,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC01_000/ov_SC01_000_after.c b/src/ov_SC01_000/ov_SC01_000_after.c index ddd81f30f1..98f07f7f21 100644 --- a/src/ov_SC01_000/ov_SC01_000_after.c +++ b/src/ov_SC01_000/ov_SC01_000_after.c @@ -901,52 +901,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1122,50 +1077,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1338,38 +1250,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1591,38 +1472,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2088,41 +1938,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC01_000/ov_SC01_000_jr_8012ACE0.c b/src/ov_SC01_000/ov_SC01_000_jr_8012ACE0.c index fe95e66dc5..f441e6b3ac 100644 --- a/src/ov_SC01_000/ov_SC01_000_jr_8012ACE0.c +++ b/src/ov_SC01_000/ov_SC01_000_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1111,23 +1069,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1160,29 +1102,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1944,25 +1864,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2065,15 +1967,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2105,37 +1999,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2551,35 +2415,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC01_000/ov_SC01_000_jr_80135D20.c b/src/ov_SC01_000/ov_SC01_000_jr_80135D20.c index d31fd7763a..1ed5e7672c 100644 --- a/src/ov_SC01_000/ov_SC01_000_jr_80135D20.c +++ b/src/ov_SC01_000/ov_SC01_000_jr_80135D20.c @@ -1341,17 +1341,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1395,32 +1385,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC01_000/ov_SC01_000_jr_801380E0.c b/src/ov_SC01_000/ov_SC01_000_jr_801380E0.c index 225da2bcbc..8fc75b0655 100644 --- a/src/ov_SC01_000/ov_SC01_000_jr_801380E0.c +++ b/src/ov_SC01_000/ov_SC01_000_jr_801380E0.c @@ -1092,43 +1092,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC01_000/ov_SC01_000_jr_8015AE2C.c b/src/ov_SC01_000/ov_SC01_000_jr_8015AE2C.c index db32db06a6..d1de1f0536 100644 --- a/src/ov_SC01_000/ov_SC01_000_jr_8015AE2C.c +++ b/src/ov_SC01_000/ov_SC01_000_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC01_000/ov_SC01_000_jr_8015C32C.c b/src/ov_SC01_000/ov_SC01_000_jr_8015C32C.c index 738cfdda84..e7dec5509d 100644 --- a/src/ov_SC01_000/ov_SC01_000_jr_8015C32C.c +++ b/src/ov_SC01_000/ov_SC01_000_jr_8015C32C.c @@ -3355,31 +3355,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3504,58 +3480,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4191,21 +4116,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4281,51 +4192,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5397,23 +5264,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC01_000/ov_SC01_000_jr_8016AB6C.c b/src/ov_SC01_000/ov_SC01_000_jr_8016AB6C.c index 127570558b..e145f185ff 100644 --- a/src/ov_SC01_000/ov_SC01_000_jr_8016AB6C.c +++ b/src/ov_SC01_000/ov_SC01_000_jr_8016AB6C.c @@ -2557,21 +2557,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3894,37 +3880,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4290,26 +4246,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4361,38 +4298,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC01_000/ov_SC01_000_jr_80171B4C.c b/src/ov_SC01_000/ov_SC01_000_jr_80171B4C.c index bdad46752f..ab8c3953ed 100644 --- a/src/ov_SC01_000/ov_SC01_000_jr_80171B4C.c +++ b/src/ov_SC01_000/ov_SC01_000_jr_80171B4C.c @@ -2429,14 +2429,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2553,18 +2546,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC01_000/ov_SC01_000_jr_801734BC.c b/src/ov_SC01_000/ov_SC01_000_jr_801734BC.c index eb7662e3aa..86edf6a807 100644 --- a/src/ov_SC01_000/ov_SC01_000_jr_801734BC.c +++ b/src/ov_SC01_000/ov_SC01_000_jr_801734BC.c @@ -2415,40 +2415,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2911,38 +2878,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ /* func_801758FC — twin of the byte-matched func_80175820 / func_801759D8 in this same TU. @@ -2965,44 +2901,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3793,41 +3692,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC01_000/ov_SC01_000_o0c.c b/src/ov_SC01_000/ov_SC01_000_o0c.c index 1a085af11c..fce252ed1a 100644 --- a/src/ov_SC01_000/ov_SC01_000_o0c.c +++ b/src/ov_SC01_000/ov_SC01_000_o0c.c @@ -1016,24 +1016,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC01_001/ov_SC01_001.c b/src/ov_SC01_001/ov_SC01_001.c index 64e3292aef..5c4b961f8f 100644 --- a/src/ov_SC01_001/ov_SC01_001.c +++ b/src/ov_SC01_001/ov_SC01_001.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC01_001/ov_SC01_001_after.c b/src/ov_SC01_001/ov_SC01_001_after.c index 7f7120d16b..ea830b8f6a 100644 --- a/src/ov_SC01_001/ov_SC01_001_after.c +++ b/src/ov_SC01_001/ov_SC01_001_after.c @@ -901,52 +901,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1122,50 +1077,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1338,38 +1250,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1591,38 +1472,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2088,41 +1938,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC01_001/ov_SC01_001_jr_8012ACE0.c b/src/ov_SC01_001/ov_SC01_001_jr_8012ACE0.c index a4d618ef9a..68462919ec 100644 --- a/src/ov_SC01_001/ov_SC01_001_jr_8012ACE0.c +++ b/src/ov_SC01_001/ov_SC01_001_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2551,35 +2415,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC01_001/ov_SC01_001_jr_80135D20.c b/src/ov_SC01_001/ov_SC01_001_jr_80135D20.c index 35b450eb3c..00a1748d2c 100644 --- a/src/ov_SC01_001/ov_SC01_001_jr_80135D20.c +++ b/src/ov_SC01_001/ov_SC01_001_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC01_001/ov_SC01_001_jr_801380E0.c b/src/ov_SC01_001/ov_SC01_001_jr_801380E0.c index 32c33986ca..4cf55b93dc 100644 --- a/src/ov_SC01_001/ov_SC01_001_jr_801380E0.c +++ b/src/ov_SC01_001/ov_SC01_001_jr_801380E0.c @@ -1092,43 +1092,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC01_001/ov_SC01_001_jr_8015AE2C.c b/src/ov_SC01_001/ov_SC01_001_jr_8015AE2C.c index f80705f319..0cfd638637 100644 --- a/src/ov_SC01_001/ov_SC01_001_jr_8015AE2C.c +++ b/src/ov_SC01_001/ov_SC01_001_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC01_001/ov_SC01_001_jr_8015C32C.c b/src/ov_SC01_001/ov_SC01_001_jr_8015C32C.c index 6ec00b8b5c..695139d76a 100644 --- a/src/ov_SC01_001/ov_SC01_001_jr_8015C32C.c +++ b/src/ov_SC01_001/ov_SC01_001_jr_8015C32C.c @@ -3352,31 +3352,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3501,58 +3477,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4188,21 +4113,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4278,51 +4189,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5392,25 +5259,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC01_001/ov_SC01_001_jr_8016AB6C.c b/src/ov_SC01_001/ov_SC01_001_jr_8016AB6C.c index 9dfbe79c1d..fd99ea3d5a 100644 --- a/src/ov_SC01_001/ov_SC01_001_jr_8016AB6C.c +++ b/src/ov_SC01_001/ov_SC01_001_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4288,26 +4244,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4359,38 +4296,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC01_001/ov_SC01_001_jr_80171B4C.c b/src/ov_SC01_001/ov_SC01_001_jr_80171B4C.c index 16a166fecd..5e57eed497 100644 --- a/src/ov_SC01_001/ov_SC01_001_jr_80171B4C.c +++ b/src/ov_SC01_001/ov_SC01_001_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC01_001/ov_SC01_001_jr_801734BC.c b/src/ov_SC01_001/ov_SC01_001_jr_801734BC.c index 7df80275b4..02c57bd89d 100644 --- a/src/ov_SC01_001/ov_SC01_001_jr_801734BC.c +++ b/src/ov_SC01_001/ov_SC01_001_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC01_001/ov_SC01_001_o0c.c b/src/ov_SC01_001/ov_SC01_001_o0c.c index d9826e486b..f631860fdc 100644 --- a/src/ov_SC01_001/ov_SC01_001_o0c.c +++ b/src/ov_SC01_001/ov_SC01_001_o0c.c @@ -1017,24 +1017,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC01_004/ov_SC01_004.c b/src/ov_SC01_004/ov_SC01_004.c index cc70982022..4c4797fecd 100644 --- a/src/ov_SC01_004/ov_SC01_004.c +++ b/src/ov_SC01_004/ov_SC01_004.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC01_004/ov_SC01_004_after.c b/src/ov_SC01_004/ov_SC01_004_after.c index 1174dd3b74..e35475660c 100644 --- a/src/ov_SC01_004/ov_SC01_004_after.c +++ b/src/ov_SC01_004/ov_SC01_004_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC01_004/ov_SC01_004_jr_8012ACE0.c b/src/ov_SC01_004/ov_SC01_004_jr_8012ACE0.c index 0ac402d3f7..7b6055a3fd 100644 --- a/src/ov_SC01_004/ov_SC01_004_jr_8012ACE0.c +++ b/src/ov_SC01_004/ov_SC01_004_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC01_004/ov_SC01_004_jr_80135D20.c b/src/ov_SC01_004/ov_SC01_004_jr_80135D20.c index 3376bb7471..d3bb459d5a 100644 --- a/src/ov_SC01_004/ov_SC01_004_jr_80135D20.c +++ b/src/ov_SC01_004/ov_SC01_004_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC01_004/ov_SC01_004_jr_801380E0.c b/src/ov_SC01_004/ov_SC01_004_jr_801380E0.c index 4f62ef44ab..26c223e44c 100644 --- a/src/ov_SC01_004/ov_SC01_004_jr_801380E0.c +++ b/src/ov_SC01_004/ov_SC01_004_jr_801380E0.c @@ -1100,43 +1100,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC01_004/ov_SC01_004_jr_8015AE2C.c b/src/ov_SC01_004/ov_SC01_004_jr_8015AE2C.c index 40aba02391..77dd742b8c 100644 --- a/src/ov_SC01_004/ov_SC01_004_jr_8015AE2C.c +++ b/src/ov_SC01_004/ov_SC01_004_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC01_004/ov_SC01_004_jr_8015C32C.c b/src/ov_SC01_004/ov_SC01_004_jr_8015C32C.c index 42ca6f08b2..7444b607f7 100644 --- a/src/ov_SC01_004/ov_SC01_004_jr_8015C32C.c +++ b/src/ov_SC01_004/ov_SC01_004_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC01_004/ov_SC01_004_jr_8016AB6C.c b/src/ov_SC01_004/ov_SC01_004_jr_8016AB6C.c index d5bd686ff6..211c9f0149 100644 --- a/src/ov_SC01_004/ov_SC01_004_jr_8016AB6C.c +++ b/src/ov_SC01_004/ov_SC01_004_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4288,26 +4244,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4359,38 +4296,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC01_004/ov_SC01_004_jr_80171B4C.c b/src/ov_SC01_004/ov_SC01_004_jr_80171B4C.c index 7720b4b742..484ee5599d 100644 --- a/src/ov_SC01_004/ov_SC01_004_jr_80171B4C.c +++ b/src/ov_SC01_004/ov_SC01_004_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC01_004/ov_SC01_004_jr_801734BC.c b/src/ov_SC01_004/ov_SC01_004_jr_801734BC.c index 5750f94378..0c67fb0870 100644 --- a/src/ov_SC01_004/ov_SC01_004_jr_801734BC.c +++ b/src/ov_SC01_004/ov_SC01_004_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC01_004/ov_SC01_004_o0c.c b/src/ov_SC01_004/ov_SC01_004_o0c.c index 26ba03bbb2..d2e2cc9676 100644 --- a/src/ov_SC01_004/ov_SC01_004_o0c.c +++ b/src/ov_SC01_004/ov_SC01_004_o0c.c @@ -1017,24 +1017,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC01_005/ov_SC01_005.c b/src/ov_SC01_005/ov_SC01_005.c index bd770bb71b..c5962263b0 100644 --- a/src/ov_SC01_005/ov_SC01_005.c +++ b/src/ov_SC01_005/ov_SC01_005.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC01_005/ov_SC01_005_after.c b/src/ov_SC01_005/ov_SC01_005_after.c index d7b4c743cb..ec139d4e9d 100644 --- a/src/ov_SC01_005/ov_SC01_005_after.c +++ b/src/ov_SC01_005/ov_SC01_005_after.c @@ -904,52 +904,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1125,50 +1080,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1341,38 +1253,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1594,38 +1475,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2091,41 +1941,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC01_005/ov_SC01_005_jr_8012ACE0.c b/src/ov_SC01_005/ov_SC01_005_jr_8012ACE0.c index 27e7c99544..0045c319c3 100644 --- a/src/ov_SC01_005/ov_SC01_005_jr_8012ACE0.c +++ b/src/ov_SC01_005/ov_SC01_005_jr_8012ACE0.c @@ -326,49 +326,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1095,23 +1053,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1144,29 +1086,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1928,25 +1848,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2049,15 +1951,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2089,37 +1983,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2543,35 +2407,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC01_005/ov_SC01_005_jr_80135D20.c b/src/ov_SC01_005/ov_SC01_005_jr_80135D20.c index 2855ce92dc..7da41f71ae 100644 --- a/src/ov_SC01_005/ov_SC01_005_jr_80135D20.c +++ b/src/ov_SC01_005/ov_SC01_005_jr_80135D20.c @@ -1341,17 +1341,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1395,32 +1385,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC01_005/ov_SC01_005_jr_801380E0.c b/src/ov_SC01_005/ov_SC01_005_jr_801380E0.c index 5475c51fc5..7d5ff253d3 100644 --- a/src/ov_SC01_005/ov_SC01_005_jr_801380E0.c +++ b/src/ov_SC01_005/ov_SC01_005_jr_801380E0.c @@ -1093,43 +1093,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC01_005/ov_SC01_005_jr_8015AE2C.c b/src/ov_SC01_005/ov_SC01_005_jr_8015AE2C.c index f719948ce5..d7aa86ff01 100644 --- a/src/ov_SC01_005/ov_SC01_005_jr_8015AE2C.c +++ b/src/ov_SC01_005/ov_SC01_005_jr_8015AE2C.c @@ -1817,20 +1817,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC01_005/ov_SC01_005_jr_8015C32C.c b/src/ov_SC01_005/ov_SC01_005_jr_8015C32C.c index a76c7f626d..934ca3a7d8 100644 --- a/src/ov_SC01_005/ov_SC01_005_jr_8015C32C.c +++ b/src/ov_SC01_005/ov_SC01_005_jr_8015C32C.c @@ -3355,31 +3355,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3504,58 +3480,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4191,21 +4116,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4281,51 +4192,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5395,25 +5262,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC01_005/ov_SC01_005_jr_8016AB6C.c b/src/ov_SC01_005/ov_SC01_005_jr_8016AB6C.c index a95c2f0d85..65f6880b35 100644 --- a/src/ov_SC01_005/ov_SC01_005_jr_8016AB6C.c +++ b/src/ov_SC01_005/ov_SC01_005_jr_8016AB6C.c @@ -2556,21 +2556,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3893,37 +3879,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4288,26 +4244,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4359,38 +4296,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC01_005/ov_SC01_005_jr_80171B4C.c b/src/ov_SC01_005/ov_SC01_005_jr_80171B4C.c index 4250144153..9c14b99dc7 100644 --- a/src/ov_SC01_005/ov_SC01_005_jr_80171B4C.c +++ b/src/ov_SC01_005/ov_SC01_005_jr_80171B4C.c @@ -2424,14 +2424,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2548,18 +2541,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC01_005/ov_SC01_005_jr_801734BC.c b/src/ov_SC01_005/ov_SC01_005_jr_801734BC.c index a3e6007436..a03920d91d 100644 --- a/src/ov_SC01_005/ov_SC01_005_jr_801734BC.c +++ b/src/ov_SC01_005/ov_SC01_005_jr_801734BC.c @@ -2414,40 +2414,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC01_005/ov_SC01_005_o0c.c b/src/ov_SC01_005/ov_SC01_005_o0c.c index ff701fddf4..9e94d26eb8 100644 --- a/src/ov_SC01_005/ov_SC01_005_o0c.c +++ b/src/ov_SC01_005/ov_SC01_005_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC01_006/ov_SC01_006.c b/src/ov_SC01_006/ov_SC01_006.c index bd770bb71b..c5962263b0 100644 --- a/src/ov_SC01_006/ov_SC01_006.c +++ b/src/ov_SC01_006/ov_SC01_006.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC01_006/ov_SC01_006_after.c b/src/ov_SC01_006/ov_SC01_006_after.c index c77f9a64d1..4ab2d30184 100644 --- a/src/ov_SC01_006/ov_SC01_006_after.c +++ b/src/ov_SC01_006/ov_SC01_006_after.c @@ -904,52 +904,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1125,50 +1080,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1341,38 +1253,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1594,38 +1475,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2091,41 +1941,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC01_006/ov_SC01_006_jr_8012ACE0.c b/src/ov_SC01_006/ov_SC01_006_jr_8012ACE0.c index e0ca3d84a5..01ccc049a2 100644 --- a/src/ov_SC01_006/ov_SC01_006_jr_8012ACE0.c +++ b/src/ov_SC01_006/ov_SC01_006_jr_8012ACE0.c @@ -326,49 +326,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1095,23 +1053,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1144,29 +1086,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1928,25 +1848,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2049,15 +1951,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2089,37 +1983,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2543,35 +2407,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC01_006/ov_SC01_006_jr_80135D20.c b/src/ov_SC01_006/ov_SC01_006_jr_80135D20.c index 2855ce92dc..7da41f71ae 100644 --- a/src/ov_SC01_006/ov_SC01_006_jr_80135D20.c +++ b/src/ov_SC01_006/ov_SC01_006_jr_80135D20.c @@ -1341,17 +1341,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1395,32 +1385,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC01_006/ov_SC01_006_jr_801380E0.c b/src/ov_SC01_006/ov_SC01_006_jr_801380E0.c index 5475c51fc5..7d5ff253d3 100644 --- a/src/ov_SC01_006/ov_SC01_006_jr_801380E0.c +++ b/src/ov_SC01_006/ov_SC01_006_jr_801380E0.c @@ -1093,43 +1093,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC01_006/ov_SC01_006_jr_8015AE2C.c b/src/ov_SC01_006/ov_SC01_006_jr_8015AE2C.c index f719948ce5..d7aa86ff01 100644 --- a/src/ov_SC01_006/ov_SC01_006_jr_8015AE2C.c +++ b/src/ov_SC01_006/ov_SC01_006_jr_8015AE2C.c @@ -1817,20 +1817,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC01_006/ov_SC01_006_jr_8015C32C.c b/src/ov_SC01_006/ov_SC01_006_jr_8015C32C.c index a76c7f626d..934ca3a7d8 100644 --- a/src/ov_SC01_006/ov_SC01_006_jr_8015C32C.c +++ b/src/ov_SC01_006/ov_SC01_006_jr_8015C32C.c @@ -3355,31 +3355,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3504,58 +3480,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4191,21 +4116,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4281,51 +4192,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5395,25 +5262,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC01_006/ov_SC01_006_jr_8016AB6C.c b/src/ov_SC01_006/ov_SC01_006_jr_8016AB6C.c index a95c2f0d85..65f6880b35 100644 --- a/src/ov_SC01_006/ov_SC01_006_jr_8016AB6C.c +++ b/src/ov_SC01_006/ov_SC01_006_jr_8016AB6C.c @@ -2556,21 +2556,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3893,37 +3879,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4288,26 +4244,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4359,38 +4296,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC01_006/ov_SC01_006_jr_80171B4C.c b/src/ov_SC01_006/ov_SC01_006_jr_80171B4C.c index 4250144153..9c14b99dc7 100644 --- a/src/ov_SC01_006/ov_SC01_006_jr_80171B4C.c +++ b/src/ov_SC01_006/ov_SC01_006_jr_80171B4C.c @@ -2424,14 +2424,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2548,18 +2541,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC01_006/ov_SC01_006_jr_801734BC.c b/src/ov_SC01_006/ov_SC01_006_jr_801734BC.c index a3e6007436..a03920d91d 100644 --- a/src/ov_SC01_006/ov_SC01_006_jr_801734BC.c +++ b/src/ov_SC01_006/ov_SC01_006_jr_801734BC.c @@ -2414,40 +2414,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC01_006/ov_SC01_006_o0c.c b/src/ov_SC01_006/ov_SC01_006_o0c.c index ff701fddf4..9e94d26eb8 100644 --- a/src/ov_SC01_006/ov_SC01_006_o0c.c +++ b/src/ov_SC01_006/ov_SC01_006_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC01_008/ov_SC01_008.c b/src/ov_SC01_008/ov_SC01_008.c index 50330c664b..bc83f24ff9 100644 --- a/src/ov_SC01_008/ov_SC01_008.c +++ b/src/ov_SC01_008/ov_SC01_008.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC01_008/ov_SC01_008_after.c b/src/ov_SC01_008/ov_SC01_008_after.c index 9b11e9d122..a2d6587331 100644 --- a/src/ov_SC01_008/ov_SC01_008_after.c +++ b/src/ov_SC01_008/ov_SC01_008_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC01_008/ov_SC01_008_jr_8012ACE0.c b/src/ov_SC01_008/ov_SC01_008_jr_8012ACE0.c index 2509ed7204..ff17d28925 100644 --- a/src/ov_SC01_008/ov_SC01_008_jr_8012ACE0.c +++ b/src/ov_SC01_008/ov_SC01_008_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC01_008/ov_SC01_008_jr_80135D20.c b/src/ov_SC01_008/ov_SC01_008_jr_80135D20.c index 02ea5cec0b..17f9202717 100644 --- a/src/ov_SC01_008/ov_SC01_008_jr_80135D20.c +++ b/src/ov_SC01_008/ov_SC01_008_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC01_008/ov_SC01_008_jr_801380E0.c b/src/ov_SC01_008/ov_SC01_008_jr_801380E0.c index 247e04f817..0b20964628 100644 --- a/src/ov_SC01_008/ov_SC01_008_jr_801380E0.c +++ b/src/ov_SC01_008/ov_SC01_008_jr_801380E0.c @@ -1100,43 +1100,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC01_008/ov_SC01_008_jr_8015AE2C.c b/src/ov_SC01_008/ov_SC01_008_jr_8015AE2C.c index 90498f1213..b5eb48fc8c 100644 --- a/src/ov_SC01_008/ov_SC01_008_jr_8015AE2C.c +++ b/src/ov_SC01_008/ov_SC01_008_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC01_008/ov_SC01_008_jr_8015C32C.c b/src/ov_SC01_008/ov_SC01_008_jr_8015C32C.c index 9cd7485d79..45fa1fe4f4 100644 --- a/src/ov_SC01_008/ov_SC01_008_jr_8015C32C.c +++ b/src/ov_SC01_008/ov_SC01_008_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC01_008/ov_SC01_008_jr_8016AB6C.c b/src/ov_SC01_008/ov_SC01_008_jr_8016AB6C.c index c3891261b9..2f778d3b9a 100644 --- a/src/ov_SC01_008/ov_SC01_008_jr_8016AB6C.c +++ b/src/ov_SC01_008/ov_SC01_008_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC01_008/ov_SC01_008_jr_80171B4C.c b/src/ov_SC01_008/ov_SC01_008_jr_80171B4C.c index 5df25cbc16..ab648a0a79 100644 --- a/src/ov_SC01_008/ov_SC01_008_jr_80171B4C.c +++ b/src/ov_SC01_008/ov_SC01_008_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC01_008/ov_SC01_008_jr_801734BC.c b/src/ov_SC01_008/ov_SC01_008_jr_801734BC.c index 4d74f9dc15..4da8c25e97 100644 --- a/src/ov_SC01_008/ov_SC01_008_jr_801734BC.c +++ b/src/ov_SC01_008/ov_SC01_008_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC01_008/ov_SC01_008_o0c.c b/src/ov_SC01_008/ov_SC01_008_o0c.c index 6c417c4090..7ecce620ae 100644 --- a/src/ov_SC01_008/ov_SC01_008_o0c.c +++ b/src/ov_SC01_008/ov_SC01_008_o0c.c @@ -1017,24 +1017,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC01_009/ov_SC01_009.c b/src/ov_SC01_009/ov_SC01_009.c index d741444349..3313785d35 100644 --- a/src/ov_SC01_009/ov_SC01_009.c +++ b/src/ov_SC01_009/ov_SC01_009.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC01_009/ov_SC01_009_after.c b/src/ov_SC01_009/ov_SC01_009_after.c index b235c41a2b..21d271c053 100644 --- a/src/ov_SC01_009/ov_SC01_009_after.c +++ b/src/ov_SC01_009/ov_SC01_009_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC01_009/ov_SC01_009_jr_8012ACE0.c b/src/ov_SC01_009/ov_SC01_009_jr_8012ACE0.c index e90c20570a..02bf8f1e18 100644 --- a/src/ov_SC01_009/ov_SC01_009_jr_8012ACE0.c +++ b/src/ov_SC01_009/ov_SC01_009_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC01_009/ov_SC01_009_jr_80135D20.c b/src/ov_SC01_009/ov_SC01_009_jr_80135D20.c index 9a12660c1b..04892a9302 100644 --- a/src/ov_SC01_009/ov_SC01_009_jr_80135D20.c +++ b/src/ov_SC01_009/ov_SC01_009_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC01_009/ov_SC01_009_jr_801380E0.c b/src/ov_SC01_009/ov_SC01_009_jr_801380E0.c index 4ac4ea9288..d7036ceaa0 100644 --- a/src/ov_SC01_009/ov_SC01_009_jr_801380E0.c +++ b/src/ov_SC01_009/ov_SC01_009_jr_801380E0.c @@ -1100,43 +1100,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC01_009/ov_SC01_009_jr_8015AE2C.c b/src/ov_SC01_009/ov_SC01_009_jr_8015AE2C.c index c93fb1e9b5..2fe35a4d49 100644 --- a/src/ov_SC01_009/ov_SC01_009_jr_8015AE2C.c +++ b/src/ov_SC01_009/ov_SC01_009_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC01_009/ov_SC01_009_jr_8015C32C.c b/src/ov_SC01_009/ov_SC01_009_jr_8015C32C.c index a156b62b87..c35ed38bcf 100644 --- a/src/ov_SC01_009/ov_SC01_009_jr_8015C32C.c +++ b/src/ov_SC01_009/ov_SC01_009_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC01_009/ov_SC01_009_jr_8016AB6C.c b/src/ov_SC01_009/ov_SC01_009_jr_8016AB6C.c index 7ec6cb51f0..3e070a1b6c 100644 --- a/src/ov_SC01_009/ov_SC01_009_jr_8016AB6C.c +++ b/src/ov_SC01_009/ov_SC01_009_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC01_009/ov_SC01_009_jr_80171B4C.c b/src/ov_SC01_009/ov_SC01_009_jr_80171B4C.c index d623a215d6..19a4a4652b 100644 --- a/src/ov_SC01_009/ov_SC01_009_jr_80171B4C.c +++ b/src/ov_SC01_009/ov_SC01_009_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC01_009/ov_SC01_009_jr_801734BC.c b/src/ov_SC01_009/ov_SC01_009_jr_801734BC.c index fd843c92c6..61cba98712 100644 --- a/src/ov_SC01_009/ov_SC01_009_jr_801734BC.c +++ b/src/ov_SC01_009/ov_SC01_009_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC01_009/ov_SC01_009_o0c.c b/src/ov_SC01_009/ov_SC01_009_o0c.c index f11028a2c5..460353f692 100644 --- a/src/ov_SC01_009/ov_SC01_009_o0c.c +++ b/src/ov_SC01_009/ov_SC01_009_o0c.c @@ -1017,24 +1017,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC01_074/ov_SC01_074.c b/src/ov_SC01_074/ov_SC01_074.c index 89acef73fa..49a1c93508 100644 --- a/src/ov_SC01_074/ov_SC01_074.c +++ b/src/ov_SC01_074/ov_SC01_074.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC01_074/ov_SC01_074_after.c b/src/ov_SC01_074/ov_SC01_074_after.c index bbdc36d7c7..4ec2e69675 100644 --- a/src/ov_SC01_074/ov_SC01_074_after.c +++ b/src/ov_SC01_074/ov_SC01_074_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC01_074/ov_SC01_074_jr_8012ACE0.c b/src/ov_SC01_074/ov_SC01_074_jr_8012ACE0.c index 20eb0dbac3..79f42936c2 100644 --- a/src/ov_SC01_074/ov_SC01_074_jr_8012ACE0.c +++ b/src/ov_SC01_074/ov_SC01_074_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC01_074/ov_SC01_074_jr_80135D20.c b/src/ov_SC01_074/ov_SC01_074_jr_80135D20.c index 119d7b923a..e9d5209268 100644 --- a/src/ov_SC01_074/ov_SC01_074_jr_80135D20.c +++ b/src/ov_SC01_074/ov_SC01_074_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC01_074/ov_SC01_074_jr_801380E0.c b/src/ov_SC01_074/ov_SC01_074_jr_801380E0.c index 8539e94d36..e3e02bc681 100644 --- a/src/ov_SC01_074/ov_SC01_074_jr_801380E0.c +++ b/src/ov_SC01_074/ov_SC01_074_jr_801380E0.c @@ -1101,43 +1101,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC01_074/ov_SC01_074_jr_8015AE2C.c b/src/ov_SC01_074/ov_SC01_074_jr_8015AE2C.c index 7db960f916..8e44788bf7 100644 --- a/src/ov_SC01_074/ov_SC01_074_jr_8015AE2C.c +++ b/src/ov_SC01_074/ov_SC01_074_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC01_074/ov_SC01_074_jr_8015C32C.c b/src/ov_SC01_074/ov_SC01_074_jr_8015C32C.c index bf5e8bef94..5dabbabe11 100644 --- a/src/ov_SC01_074/ov_SC01_074_jr_8015C32C.c +++ b/src/ov_SC01_074/ov_SC01_074_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC01_074/ov_SC01_074_jr_8016AB6C.c b/src/ov_SC01_074/ov_SC01_074_jr_8016AB6C.c index 293b49edf6..bcba81515a 100644 --- a/src/ov_SC01_074/ov_SC01_074_jr_8016AB6C.c +++ b/src/ov_SC01_074/ov_SC01_074_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC01_074/ov_SC01_074_jr_80171B4C.c b/src/ov_SC01_074/ov_SC01_074_jr_80171B4C.c index a772493962..97ec9c9923 100644 --- a/src/ov_SC01_074/ov_SC01_074_jr_80171B4C.c +++ b/src/ov_SC01_074/ov_SC01_074_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC01_074/ov_SC01_074_jr_801734BC.c b/src/ov_SC01_074/ov_SC01_074_jr_801734BC.c index dbc919dc4a..e6427aa535 100644 --- a/src/ov_SC01_074/ov_SC01_074_jr_801734BC.c +++ b/src/ov_SC01_074/ov_SC01_074_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC01_074/ov_SC01_074_o0c.c b/src/ov_SC01_074/ov_SC01_074_o0c.c index 71e48ed416..164b8c8e26 100644 --- a/src/ov_SC01_074/ov_SC01_074_o0c.c +++ b/src/ov_SC01_074/ov_SC01_074_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC01_077/ov_SC01_077_a.c b/src/ov_SC01_077/ov_SC01_077_a.c index f4b96b8931..84a97edd72 100644 --- a/src/ov_SC01_077/ov_SC01_077_a.c +++ b/src/ov_SC01_077/ov_SC01_077_a.c @@ -768,12 +768,7 @@ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ extern u8 D_80126948[]; void func_8012A048(void *a0, s32 a1, u8 a2); -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -798,40 +793,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC01_077/ov_SC01_077_after.c b/src/ov_SC01_077/ov_SC01_077_after.c index 0cb66e6f4c..9e15663da4 100644 --- a/src/ov_SC01_077/ov_SC01_077_after.c +++ b/src/ov_SC01_077/ov_SC01_077_after.c @@ -1055,31 +1055,7 @@ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT * `register __asm__("$N")` pins. */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ // @class: regalloc-order @@ -1256,49 +1232,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); -extern u8 D_801202A0[]; - -s32 func_8014A738(void *arg0) { - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1593,38 +1527,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U *)(a0 + 0x7C) = *(V4U *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ DEFINE_func_8014C568() /* dedup: shared engine-core @0x8014C568 (src/shared) */ @@ -1905,36 +1808,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ // @class: other @@ -2487,41 +2361,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ // @class: other diff --git a/src/ov_SC01_077/ov_SC01_077_jr_8012ACE0.c b/src/ov_SC01_077/ov_SC01_077_jr_8012ACE0.c index a46ef4f3ec..201e8045ac 100644 --- a/src/ov_SC01_077/ov_SC01_077_jr_8012ACE0.c +++ b/src/ov_SC01_077/ov_SC01_077_jr_8012ACE0.c @@ -398,49 +398,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1231,23 +1189,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ // @class: other @@ -1327,29 +1269,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ #include "common.h" @@ -2188,25 +2108,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern int func_80131CF4(int, int); - void *p; - - p = (void *)func_80131CF4(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2305,15 +2207,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ /* func_80131CF4 — table lookup: walk (key, value) pairs; key 0xD chains to the @@ -2343,37 +2237,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ struct S80131E00; @@ -2815,35 +2679,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * identical `Blk32` is an anonymous-tag typedef -> a same-name redefinition here * is a C89 error in the real TU). */ -extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ -extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ -extern s32 D_80126B60; -extern s32 D_80126B64; - -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ // @class: schedule diff --git a/src/ov_SC01_077/ov_SC01_077_jr_80135D20.c b/src/ov_SC01_077/ov_SC01_077_jr_80135D20.c index 5089956fb7..5cc8752683 100644 --- a/src/ov_SC01_077/ov_SC01_077_jr_80135D20.c +++ b/src/ov_SC01_077/ov_SC01_077_jr_80135D20.c @@ -1410,17 +1410,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1473,23 +1463,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC01_077/ov_SC01_077_jr_801380E0.c b/src/ov_SC01_077/ov_SC01_077_jr_801380E0.c index 9243c448bb..11e96594bc 100644 --- a/src/ov_SC01_077/ov_SC01_077_jr_801380E0.c +++ b/src/ov_SC01_077/ov_SC01_077_jr_801380E0.c @@ -1179,43 +1179,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ /* func_80138ED0 — region-a bit-unpacking / tilemap builder (159 ins, reach-134). diff --git a/src/ov_SC01_077/ov_SC01_077_jr_8015AE2C.c b/src/ov_SC01_077/ov_SC01_077_jr_8015AE2C.c index ccb8036f03..6459424927 100644 --- a/src/ov_SC01_077/ov_SC01_077_jr_8015AE2C.c +++ b/src/ov_SC01_077/ov_SC01_077_jr_8015AE2C.c @@ -1862,20 +1862,7 @@ void func_8015BFF4(void *a0) * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c b/src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c index 6072fde91a..e4aaf4b43e 100644 --- a/src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c +++ b/src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c @@ -3546,31 +3546,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3725,25 +3701,7 @@ DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ // and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical // either way — confirmed: the same body under the plain name is match_one MATCH in isolation. -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4364,21 +4322,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4453,61 +4397,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param /* canonical (sig_hints) — return type widened s32 so the `sw $v0` after the jal has a source; the hint's `void` cannot express the store. */ -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -/* canonical (sig_hints) */ -extern s32 D_80115100; -extern s32 D_80115200; -extern u16 D_80126B18[]; - -/* derived from the asm: separate lui/%lo per symbol => distinct externs */ -extern s32 D_80115204; -extern s32 D_80115208; -extern u16 D_801270B0[]; -extern u16 D_801270B2; -extern u16 D_801270B4; -/* LOAD-BEARING: D_80126B1A must be declared/stored as an ARRAY, not a scalar. - gcc-2.7.2 true_dependence() lets an in-struct MEM with an unstable (register) - address bypass a not-in-struct MEM with a stable (symbol) address. As a scalar, - the `sh %lo(D_80126B1A)` store does NOT conflict with `a5[2]`, so the block-6 - `lhu $t0,4($t0)` gets hoisted into the D_80126B1A block's load-delay slot and the - whole filler queue shifts one slot early (75 ins, no `nop`). ARRAY_REF sets - MEM_IN_STRUCT_P on the store => the two MEMs conflict => the load stays put. */ -extern u16 D_80126B1A[]; -extern u16 D_80126B1C; -extern s32 D_80114EB0; -extern s32 D_80114EC8; -extern s32 D_8011DAF0; -extern s32 D_80115298; -extern s32 D_80126734; - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5645,24 +5535,7 @@ void func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) } -extern s32 D_8011D030; -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ // @class: schedule diff --git a/src/ov_SC01_077/ov_SC01_077_jr_8016AB6C.c b/src/ov_SC01_077/ov_SC01_077_jr_8016AB6C.c index eae9ba28dd..cf11106f47 100644 --- a/src/ov_SC01_077/ov_SC01_077_jr_8016AB6C.c +++ b/src/ov_SC01_077/ov_SC01_077_jr_8016AB6C.c @@ -2710,21 +2710,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ extern void func_8016BFD0(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); @@ -4062,36 +4048,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); -extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ -extern u8 D_800B9A17; - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ /* func_8016F14C — read a packed fn-ptr+flags word at a0+0x1F8; mask off the high byte @@ -4474,25 +4431,7 @@ void func_8017084C(s32 a0) { func_801708B0((void *)a0); } -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); -extern void *D_8011F738; - -void func_801708B0(void* a0) -{ - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4549,37 +4488,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); -extern void *D_8011F738; -extern s32 D_8011F73C; -extern s32 D_8011F740; - -void func_80170CF0(void* a0) -{ - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ extern void (*D_8018A04C[])(void *); diff --git a/src/ov_SC01_077/ov_SC01_077_jr_80171B4C.c b/src/ov_SC01_077/ov_SC01_077_jr_80171B4C.c index a9a2c91a6d..311e8f065e 100644 --- a/src/ov_SC01_077/ov_SC01_077_jr_80171B4C.c +++ b/src/ov_SC01_077/ov_SC01_077_jr_80171B4C.c @@ -2687,17 +2687,7 @@ void func_801733CC(s32 a0) { struct S80126B38 { s32 a; s32 b; } __attribute__((packed)); #endif -extern void func_801734BC(s32 a0, s32 a1); -extern struct S80126B38 D_80126B38; -extern s16 D_80126B3E; -extern s16 D_80126B40; - -void func_801733FC(s32 a0, s32 a1) { - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC01_077/ov_SC01_077_jr_801734BC.c b/src/ov_SC01_077/ov_SC01_077_jr_801734BC.c index a5297367cd..2c0737f5d5 100644 --- a/src/ov_SC01_077/ov_SC01_077_jr_801734BC.c +++ b/src/ov_SC01_077/ov_SC01_077_jr_801734BC.c @@ -3073,38 +3073,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820 D_800AE7BC[]; - extern S_AF634_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -3114,44 +3083,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ // @class: regalloc-order @@ -4157,41 +4089,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ diff --git a/src/ov_SC01_080/ov_SC01_080.c b/src/ov_SC01_080/ov_SC01_080.c index dee13b7230..e5385ba053 100644 --- a/src/ov_SC01_080/ov_SC01_080.c +++ b/src/ov_SC01_080/ov_SC01_080.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC01_080/ov_SC01_080_after.c b/src/ov_SC01_080/ov_SC01_080_after.c index 356f418332..cbb295cea8 100644 --- a/src/ov_SC01_080/ov_SC01_080_after.c +++ b/src/ov_SC01_080/ov_SC01_080_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC01_080/ov_SC01_080_jr_8012ACE0.c b/src/ov_SC01_080/ov_SC01_080_jr_8012ACE0.c index bbe621e296..0fc59ef3d7 100644 --- a/src/ov_SC01_080/ov_SC01_080_jr_8012ACE0.c +++ b/src/ov_SC01_080/ov_SC01_080_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC01_080/ov_SC01_080_jr_80135D20.c b/src/ov_SC01_080/ov_SC01_080_jr_80135D20.c index 384c5181f5..33bb5a1fdc 100644 --- a/src/ov_SC01_080/ov_SC01_080_jr_80135D20.c +++ b/src/ov_SC01_080/ov_SC01_080_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC01_080/ov_SC01_080_jr_801380E0.c b/src/ov_SC01_080/ov_SC01_080_jr_801380E0.c index 403091bad8..694aad349e 100644 --- a/src/ov_SC01_080/ov_SC01_080_jr_801380E0.c +++ b/src/ov_SC01_080/ov_SC01_080_jr_801380E0.c @@ -1101,43 +1101,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 9c69b7cbd8..1dc1424af5 100644 --- a/src/ov_SC01_080/ov_SC01_080_jr_8015AE2C.c +++ b/src/ov_SC01_080/ov_SC01_080_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC01_080/ov_SC01_080_jr_8015C32C.c b/src/ov_SC01_080/ov_SC01_080_jr_8015C32C.c index 528ed7eaa6..7cfe0a9676 100644 --- a/src/ov_SC01_080/ov_SC01_080_jr_8015C32C.c +++ b/src/ov_SC01_080/ov_SC01_080_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC01_080/ov_SC01_080_jr_8016AB6C.c b/src/ov_SC01_080/ov_SC01_080_jr_8016AB6C.c index 7680bca3d0..a4c7ee2ab5 100644 --- a/src/ov_SC01_080/ov_SC01_080_jr_8016AB6C.c +++ b/src/ov_SC01_080/ov_SC01_080_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC01_080/ov_SC01_080_jr_80171B4C.c b/src/ov_SC01_080/ov_SC01_080_jr_80171B4C.c index 532e331553..6953f91ad6 100644 --- a/src/ov_SC01_080/ov_SC01_080_jr_80171B4C.c +++ b/src/ov_SC01_080/ov_SC01_080_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC01_080/ov_SC01_080_jr_801734BC.c b/src/ov_SC01_080/ov_SC01_080_jr_801734BC.c index c9d3560530..a0785da42d 100644 --- a/src/ov_SC01_080/ov_SC01_080_jr_801734BC.c +++ b/src/ov_SC01_080/ov_SC01_080_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC01_080/ov_SC01_080_o0c.c b/src/ov_SC01_080/ov_SC01_080_o0c.c index 946cb5959d..eadf020e56 100644 --- a/src/ov_SC01_080/ov_SC01_080_o0c.c +++ b/src/ov_SC01_080/ov_SC01_080_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC01_084/ov_SC01_084.c b/src/ov_SC01_084/ov_SC01_084.c index 54af92cfe5..2e6b95473e 100644 --- a/src/ov_SC01_084/ov_SC01_084.c +++ b/src/ov_SC01_084/ov_SC01_084.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC01_084/ov_SC01_084_after.c b/src/ov_SC01_084/ov_SC01_084_after.c index e6b95d1978..d7fc0f4807 100644 --- a/src/ov_SC01_084/ov_SC01_084_after.c +++ b/src/ov_SC01_084/ov_SC01_084_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC01_084/ov_SC01_084_jr_8012ACE0.c b/src/ov_SC01_084/ov_SC01_084_jr_8012ACE0.c index 68ca65eb16..3f96ad7b73 100644 --- a/src/ov_SC01_084/ov_SC01_084_jr_8012ACE0.c +++ b/src/ov_SC01_084/ov_SC01_084_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC01_084/ov_SC01_084_jr_80135D20.c b/src/ov_SC01_084/ov_SC01_084_jr_80135D20.c index 0263a623d5..3cc8520625 100644 --- a/src/ov_SC01_084/ov_SC01_084_jr_80135D20.c +++ b/src/ov_SC01_084/ov_SC01_084_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC01_084/ov_SC01_084_jr_801380E0.c b/src/ov_SC01_084/ov_SC01_084_jr_801380E0.c index 275e17cfed..5d1cedc739 100644 --- a/src/ov_SC01_084/ov_SC01_084_jr_801380E0.c +++ b/src/ov_SC01_084/ov_SC01_084_jr_801380E0.c @@ -1101,43 +1101,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 b20ecfc8dc..adee1bf2d1 100644 --- a/src/ov_SC01_084/ov_SC01_084_jr_8015AE2C.c +++ b/src/ov_SC01_084/ov_SC01_084_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC01_084/ov_SC01_084_jr_8015C32C.c b/src/ov_SC01_084/ov_SC01_084_jr_8015C32C.c index 941c00e561..3518821870 100644 --- a/src/ov_SC01_084/ov_SC01_084_jr_8015C32C.c +++ b/src/ov_SC01_084/ov_SC01_084_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC01_084/ov_SC01_084_jr_8016AB6C.c b/src/ov_SC01_084/ov_SC01_084_jr_8016AB6C.c index d7229a5f55..b6b159a8ab 100644 --- a/src/ov_SC01_084/ov_SC01_084_jr_8016AB6C.c +++ b/src/ov_SC01_084/ov_SC01_084_jr_8016AB6C.c @@ -2556,21 +2556,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3893,37 +3879,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4288,26 +4244,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4359,38 +4296,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC01_084/ov_SC01_084_jr_80171B4C.c b/src/ov_SC01_084/ov_SC01_084_jr_80171B4C.c index 66bcdf23aa..21273451ab 100644 --- a/src/ov_SC01_084/ov_SC01_084_jr_80171B4C.c +++ b/src/ov_SC01_084/ov_SC01_084_jr_80171B4C.c @@ -2424,14 +2424,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2548,18 +2541,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC01_084/ov_SC01_084_jr_801734BC.c b/src/ov_SC01_084/ov_SC01_084_jr_801734BC.c index 18e71bf0b7..d1a61d879d 100644 --- a/src/ov_SC01_084/ov_SC01_084_jr_801734BC.c +++ b/src/ov_SC01_084/ov_SC01_084_jr_801734BC.c @@ -2414,40 +2414,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC01_084/ov_SC01_084_o0c.c b/src/ov_SC01_084/ov_SC01_084_o0c.c index a066736730..17249ec315 100644 --- a/src/ov_SC01_084/ov_SC01_084_o0c.c +++ b/src/ov_SC01_084/ov_SC01_084_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_000/ov_SC02_000.c b/src/ov_SC02_000/ov_SC02_000.c index 470f058c20..7ddadef202 100644 --- a/src/ov_SC02_000/ov_SC02_000.c +++ b/src/ov_SC02_000/ov_SC02_000.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_000/ov_SC02_000_after.c b/src/ov_SC02_000/ov_SC02_000_after.c index 4913ca6bff..1b523c7acd 100644 --- a/src/ov_SC02_000/ov_SC02_000_after.c +++ b/src/ov_SC02_000/ov_SC02_000_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_000/ov_SC02_000_jr_8012ACE0.c b/src/ov_SC02_000/ov_SC02_000_jr_8012ACE0.c index 82305aeaf3..c0a6f2490a 100644 --- a/src/ov_SC02_000/ov_SC02_000_jr_8012ACE0.c +++ b/src/ov_SC02_000/ov_SC02_000_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2551,35 +2415,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_000/ov_SC02_000_jr_80135D20.c b/src/ov_SC02_000/ov_SC02_000_jr_80135D20.c index 2e4b12879e..cb75460d51 100644 --- a/src/ov_SC02_000/ov_SC02_000_jr_80135D20.c +++ b/src/ov_SC02_000/ov_SC02_000_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_000/ov_SC02_000_jr_801380E0.c b/src/ov_SC02_000/ov_SC02_000_jr_801380E0.c index 5096fa3e10..f3ddab4670 100644 --- a/src/ov_SC02_000/ov_SC02_000_jr_801380E0.c +++ b/src/ov_SC02_000/ov_SC02_000_jr_801380E0.c @@ -1092,43 +1092,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 891ffb8163..415f53f92d 100644 --- a/src/ov_SC02_000/ov_SC02_000_jr_8015AE2C.c +++ b/src/ov_SC02_000/ov_SC02_000_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_000/ov_SC02_000_jr_8015C32C.c b/src/ov_SC02_000/ov_SC02_000_jr_8015C32C.c index 9acc0eb959..96faffa40a 100644 --- a/src/ov_SC02_000/ov_SC02_000_jr_8015C32C.c +++ b/src/ov_SC02_000/ov_SC02_000_jr_8015C32C.c @@ -3352,31 +3352,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3501,58 +3477,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4188,21 +4113,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4278,51 +4189,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5392,25 +5259,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_000/ov_SC02_000_jr_8016AB6C.c b/src/ov_SC02_000/ov_SC02_000_jr_8016AB6C.c index 419bc28431..c6183eded4 100644 --- a/src/ov_SC02_000/ov_SC02_000_jr_8016AB6C.c +++ b/src/ov_SC02_000/ov_SC02_000_jr_8016AB6C.c @@ -2553,21 +2553,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3890,37 +3876,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4285,26 +4241,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4356,38 +4293,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_000/ov_SC02_000_jr_80171B4C.c b/src/ov_SC02_000/ov_SC02_000_jr_80171B4C.c index 65d0c1f2d8..b90db67baa 100644 --- a/src/ov_SC02_000/ov_SC02_000_jr_80171B4C.c +++ b/src/ov_SC02_000/ov_SC02_000_jr_80171B4C.c @@ -2421,14 +2421,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2545,18 +2538,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_000/ov_SC02_000_jr_801734BC.c b/src/ov_SC02_000/ov_SC02_000_jr_801734BC.c index e83abc4aa6..ede9f0bdcc 100644 --- a/src/ov_SC02_000/ov_SC02_000_jr_801734BC.c +++ b/src/ov_SC02_000/ov_SC02_000_jr_801734BC.c @@ -2411,40 +2411,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2617,49 +2584,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2859,38 +2784,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2900,44 +2794,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3728,41 +3585,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_000/ov_SC02_000_o0c.c b/src/ov_SC02_000/ov_SC02_000_o0c.c index fba708a6d7..93ec157813 100644 --- a/src/ov_SC02_000/ov_SC02_000_o0c.c +++ b/src/ov_SC02_000/ov_SC02_000_o0c.c @@ -1017,24 +1017,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_003/ov_SC02_003.c b/src/ov_SC02_003/ov_SC02_003.c index 470f058c20..7ddadef202 100644 --- a/src/ov_SC02_003/ov_SC02_003.c +++ b/src/ov_SC02_003/ov_SC02_003.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_003/ov_SC02_003_after.c b/src/ov_SC02_003/ov_SC02_003_after.c index cb9a123f85..1471bdfc58 100644 --- a/src/ov_SC02_003/ov_SC02_003_after.c +++ b/src/ov_SC02_003/ov_SC02_003_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_003/ov_SC02_003_jr_8012ACE0.c b/src/ov_SC02_003/ov_SC02_003_jr_8012ACE0.c index 82305aeaf3..c0a6f2490a 100644 --- a/src/ov_SC02_003/ov_SC02_003_jr_8012ACE0.c +++ b/src/ov_SC02_003/ov_SC02_003_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2551,35 +2415,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_003/ov_SC02_003_jr_80135D20.c b/src/ov_SC02_003/ov_SC02_003_jr_80135D20.c index 2e4b12879e..cb75460d51 100644 --- a/src/ov_SC02_003/ov_SC02_003_jr_80135D20.c +++ b/src/ov_SC02_003/ov_SC02_003_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_003/ov_SC02_003_jr_801380E0.c b/src/ov_SC02_003/ov_SC02_003_jr_801380E0.c index 5096fa3e10..f3ddab4670 100644 --- a/src/ov_SC02_003/ov_SC02_003_jr_801380E0.c +++ b/src/ov_SC02_003/ov_SC02_003_jr_801380E0.c @@ -1092,43 +1092,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 891ffb8163..415f53f92d 100644 --- a/src/ov_SC02_003/ov_SC02_003_jr_8015AE2C.c +++ b/src/ov_SC02_003/ov_SC02_003_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_003/ov_SC02_003_jr_8015C32C.c b/src/ov_SC02_003/ov_SC02_003_jr_8015C32C.c index 9acc0eb959..96faffa40a 100644 --- a/src/ov_SC02_003/ov_SC02_003_jr_8015C32C.c +++ b/src/ov_SC02_003/ov_SC02_003_jr_8015C32C.c @@ -3352,31 +3352,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3501,58 +3477,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4188,21 +4113,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4278,51 +4189,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5392,25 +5259,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_003/ov_SC02_003_jr_8016AB6C.c b/src/ov_SC02_003/ov_SC02_003_jr_8016AB6C.c index 419bc28431..c6183eded4 100644 --- a/src/ov_SC02_003/ov_SC02_003_jr_8016AB6C.c +++ b/src/ov_SC02_003/ov_SC02_003_jr_8016AB6C.c @@ -2553,21 +2553,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3890,37 +3876,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4285,26 +4241,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4356,38 +4293,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_003/ov_SC02_003_jr_80171B4C.c b/src/ov_SC02_003/ov_SC02_003_jr_80171B4C.c index 65d0c1f2d8..b90db67baa 100644 --- a/src/ov_SC02_003/ov_SC02_003_jr_80171B4C.c +++ b/src/ov_SC02_003/ov_SC02_003_jr_80171B4C.c @@ -2421,14 +2421,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2545,18 +2538,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_003/ov_SC02_003_jr_801734BC.c b/src/ov_SC02_003/ov_SC02_003_jr_801734BC.c index e83abc4aa6..ede9f0bdcc 100644 --- a/src/ov_SC02_003/ov_SC02_003_jr_801734BC.c +++ b/src/ov_SC02_003/ov_SC02_003_jr_801734BC.c @@ -2411,40 +2411,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2617,49 +2584,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2859,38 +2784,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2900,44 +2794,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3728,41 +3585,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_003/ov_SC02_003_o0c.c b/src/ov_SC02_003/ov_SC02_003_o0c.c index fba708a6d7..93ec157813 100644 --- a/src/ov_SC02_003/ov_SC02_003_o0c.c +++ b/src/ov_SC02_003/ov_SC02_003_o0c.c @@ -1017,24 +1017,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_004/ov_SC02_004.c b/src/ov_SC02_004/ov_SC02_004.c index 6289ebfaf7..99b75048b3 100644 --- a/src/ov_SC02_004/ov_SC02_004.c +++ b/src/ov_SC02_004/ov_SC02_004.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_004/ov_SC02_004_after.c b/src/ov_SC02_004/ov_SC02_004_after.c index 974c14eed9..24540c452f 100644 --- a/src/ov_SC02_004/ov_SC02_004_after.c +++ b/src/ov_SC02_004/ov_SC02_004_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_004/ov_SC02_004_jr_8012ACE0.c b/src/ov_SC02_004/ov_SC02_004_jr_8012ACE0.c index 4882cfc2b4..461dec1e72 100644 --- a/src/ov_SC02_004/ov_SC02_004_jr_8012ACE0.c +++ b/src/ov_SC02_004/ov_SC02_004_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_004/ov_SC02_004_jr_80135D20.c b/src/ov_SC02_004/ov_SC02_004_jr_80135D20.c index 12675093e0..77e844eb26 100644 --- a/src/ov_SC02_004/ov_SC02_004_jr_80135D20.c +++ b/src/ov_SC02_004/ov_SC02_004_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_004/ov_SC02_004_jr_801380E0.c b/src/ov_SC02_004/ov_SC02_004_jr_801380E0.c index 4cab0da42b..cd71a6abd3 100644 --- a/src/ov_SC02_004/ov_SC02_004_jr_801380E0.c +++ b/src/ov_SC02_004/ov_SC02_004_jr_801380E0.c @@ -1101,43 +1101,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 a69eb69e50..41d4095121 100644 --- a/src/ov_SC02_004/ov_SC02_004_jr_8015AE2C.c +++ b/src/ov_SC02_004/ov_SC02_004_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_004/ov_SC02_004_jr_8015C32C.c b/src/ov_SC02_004/ov_SC02_004_jr_8015C32C.c index 395525d028..c7aa8a7e4d 100644 --- a/src/ov_SC02_004/ov_SC02_004_jr_8015C32C.c +++ b/src/ov_SC02_004/ov_SC02_004_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_004/ov_SC02_004_jr_8016AB6C.c b/src/ov_SC02_004/ov_SC02_004_jr_8016AB6C.c index b78b3b4d34..b87aab7125 100644 --- a/src/ov_SC02_004/ov_SC02_004_jr_8016AB6C.c +++ b/src/ov_SC02_004/ov_SC02_004_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_004/ov_SC02_004_jr_80171B4C.c b/src/ov_SC02_004/ov_SC02_004_jr_80171B4C.c index 4e210cda82..032e3a40f6 100644 --- a/src/ov_SC02_004/ov_SC02_004_jr_80171B4C.c +++ b/src/ov_SC02_004/ov_SC02_004_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_004/ov_SC02_004_jr_801734BC.c b/src/ov_SC02_004/ov_SC02_004_jr_801734BC.c index fa45375f89..db1063af2f 100644 --- a/src/ov_SC02_004/ov_SC02_004_jr_801734BC.c +++ b/src/ov_SC02_004/ov_SC02_004_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_004/ov_SC02_004_o0c.c b/src/ov_SC02_004/ov_SC02_004_o0c.c index 85694d0536..96e4ff414b 100644 --- a/src/ov_SC02_004/ov_SC02_004_o0c.c +++ b/src/ov_SC02_004/ov_SC02_004_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_005/ov_SC02_005.c b/src/ov_SC02_005/ov_SC02_005.c index 668d007301..118ee09302 100644 --- a/src/ov_SC02_005/ov_SC02_005.c +++ b/src/ov_SC02_005/ov_SC02_005.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_005/ov_SC02_005_after.c b/src/ov_SC02_005/ov_SC02_005_after.c index fa83a32e08..ee11998ff0 100644 --- a/src/ov_SC02_005/ov_SC02_005_after.c +++ b/src/ov_SC02_005/ov_SC02_005_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_005/ov_SC02_005_jr_8012ACE0.c b/src/ov_SC02_005/ov_SC02_005_jr_8012ACE0.c index 83b39f28a6..ccb5542d29 100644 --- a/src/ov_SC02_005/ov_SC02_005_jr_8012ACE0.c +++ b/src/ov_SC02_005/ov_SC02_005_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_005/ov_SC02_005_jr_80135D20.c b/src/ov_SC02_005/ov_SC02_005_jr_80135D20.c index f408b909e4..b99bb74409 100644 --- a/src/ov_SC02_005/ov_SC02_005_jr_80135D20.c +++ b/src/ov_SC02_005/ov_SC02_005_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_005/ov_SC02_005_jr_801380E0.c b/src/ov_SC02_005/ov_SC02_005_jr_801380E0.c index 85d4319646..2251d2807e 100644 --- a/src/ov_SC02_005/ov_SC02_005_jr_801380E0.c +++ b/src/ov_SC02_005/ov_SC02_005_jr_801380E0.c @@ -1101,43 +1101,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 f98e2492b2..8be73caa66 100644 --- a/src/ov_SC02_005/ov_SC02_005_jr_8015AE2C.c +++ b/src/ov_SC02_005/ov_SC02_005_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_005/ov_SC02_005_jr_8015C32C.c b/src/ov_SC02_005/ov_SC02_005_jr_8015C32C.c index 6dbb70bfca..67254da426 100644 --- a/src/ov_SC02_005/ov_SC02_005_jr_8015C32C.c +++ b/src/ov_SC02_005/ov_SC02_005_jr_8015C32C.c @@ -3352,31 +3352,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3501,58 +3477,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4188,21 +4113,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4278,51 +4189,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5392,25 +5259,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_005/ov_SC02_005_jr_8016AB6C.c b/src/ov_SC02_005/ov_SC02_005_jr_8016AB6C.c index 069d486259..38b4c561ad 100644 --- a/src/ov_SC02_005/ov_SC02_005_jr_8016AB6C.c +++ b/src/ov_SC02_005/ov_SC02_005_jr_8016AB6C.c @@ -2557,21 +2557,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3894,37 +3880,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4289,26 +4245,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4360,38 +4297,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_005/ov_SC02_005_jr_80171B4C.c b/src/ov_SC02_005/ov_SC02_005_jr_80171B4C.c index ad2bfb5125..89caacc0cb 100644 --- a/src/ov_SC02_005/ov_SC02_005_jr_80171B4C.c +++ b/src/ov_SC02_005/ov_SC02_005_jr_80171B4C.c @@ -2425,14 +2425,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2549,18 +2542,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_005/ov_SC02_005_jr_801734BC.c b/src/ov_SC02_005/ov_SC02_005_jr_801734BC.c index ce7239e8da..a9b86259a9 100644 --- a/src/ov_SC02_005/ov_SC02_005_jr_801734BC.c +++ b/src/ov_SC02_005/ov_SC02_005_jr_801734BC.c @@ -2415,40 +2415,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2621,49 +2588,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2863,38 +2788,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2904,44 +2798,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3732,41 +3589,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_005/ov_SC02_005_o0c.c b/src/ov_SC02_005/ov_SC02_005_o0c.c index 58fb5c246b..a4b4f3b9ae 100644 --- a/src/ov_SC02_005/ov_SC02_005_o0c.c +++ b/src/ov_SC02_005/ov_SC02_005_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_011/ov_SC02_011.c b/src/ov_SC02_011/ov_SC02_011.c index d8ee5eeb1f..1e6604f4e5 100644 --- a/src/ov_SC02_011/ov_SC02_011.c +++ b/src/ov_SC02_011/ov_SC02_011.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_011/ov_SC02_011_after.c b/src/ov_SC02_011/ov_SC02_011_after.c index d8498e9d8e..93e8c8dfa0 100644 --- a/src/ov_SC02_011/ov_SC02_011_after.c +++ b/src/ov_SC02_011/ov_SC02_011_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_011/ov_SC02_011_jr_8012ACE0.c b/src/ov_SC02_011/ov_SC02_011_jr_8012ACE0.c index aaee399d5a..18e4f29528 100644 --- a/src/ov_SC02_011/ov_SC02_011_jr_8012ACE0.c +++ b/src/ov_SC02_011/ov_SC02_011_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_011/ov_SC02_011_jr_80135D20.c b/src/ov_SC02_011/ov_SC02_011_jr_80135D20.c index a310487166..a5690ba772 100644 --- a/src/ov_SC02_011/ov_SC02_011_jr_80135D20.c +++ b/src/ov_SC02_011/ov_SC02_011_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_011/ov_SC02_011_jr_801380E0.c b/src/ov_SC02_011/ov_SC02_011_jr_801380E0.c index bf743dcb98..fc9dede5ed 100644 --- a/src/ov_SC02_011/ov_SC02_011_jr_801380E0.c +++ b/src/ov_SC02_011/ov_SC02_011_jr_801380E0.c @@ -1101,43 +1101,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 4b22c5ab13..a9f29de2cb 100644 --- a/src/ov_SC02_011/ov_SC02_011_jr_8015AE2C.c +++ b/src/ov_SC02_011/ov_SC02_011_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_011/ov_SC02_011_jr_8015C32C.c b/src/ov_SC02_011/ov_SC02_011_jr_8015C32C.c index 75bb038492..9d5c9de78e 100644 --- a/src/ov_SC02_011/ov_SC02_011_jr_8015C32C.c +++ b/src/ov_SC02_011/ov_SC02_011_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_011/ov_SC02_011_jr_8016AB6C.c b/src/ov_SC02_011/ov_SC02_011_jr_8016AB6C.c index c9e600f5cd..b8c6c22094 100644 --- a/src/ov_SC02_011/ov_SC02_011_jr_8016AB6C.c +++ b/src/ov_SC02_011/ov_SC02_011_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_011/ov_SC02_011_jr_80171B4C.c b/src/ov_SC02_011/ov_SC02_011_jr_80171B4C.c index 14ef32b4f2..5bdaed1b29 100644 --- a/src/ov_SC02_011/ov_SC02_011_jr_80171B4C.c +++ b/src/ov_SC02_011/ov_SC02_011_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_011/ov_SC02_011_jr_801734BC.c b/src/ov_SC02_011/ov_SC02_011_jr_801734BC.c index 328abbb85a..d3116f1735 100644 --- a/src/ov_SC02_011/ov_SC02_011_jr_801734BC.c +++ b/src/ov_SC02_011/ov_SC02_011_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_011/ov_SC02_011_jr_8017AE2C.c b/src/ov_SC02_011/ov_SC02_011_jr_8017AE2C.c index edd92fd5fd..9b5b37f615 100644 --- a/src/ov_SC02_011/ov_SC02_011_jr_8017AE2C.c +++ b/src/ov_SC02_011/ov_SC02_011_jr_8017AE2C.c @@ -5131,8 +5131,7 @@ extern void func_80147060(u8 *a0); INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8017AE2C", func_8017E4D8); -void func_8017E518(void) { -} +DEFINE_func_8017E518() /* dedup: shared engine-core @0x8017E518 (src/shared) */ extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); @@ -9490,7 +9489,33 @@ void func_8018C424(int param_1) INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8017AE2C", func_8018C47C); -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8017AE2C", func_8018C534); +#include "common.h" + +extern void func_8012C1B8(void); +extern void func_8012CAE4(void*); +extern void func_8001C214(s32, s32); +extern s32 D_801D8AD8; + +void func_8018C534(int param_1) +{ + int v0; + int v1; + int temp; + + v0 = ((int (*)(void))func_8012C1B8)(); + *(int *)(param_1 + 0x20) = v0; + if (v0 == 0) { + ((void (*)(int))func_8012CAE4)(param_1); + } else { + ((int (*)(int, void *))func_8001C214)(v0, &D_801D8AD8); + temp = *(int *)(param_1 + 0x64); + v1 = *(unsigned short *)(temp + 0x36); + *(short *)(param_1 + 0x2) = 1; + *(short *)(param_1 + 0xFE) = 0x7FFF; + *(short *)(param_1 + 0xFC) = v1; + } +} + INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8017AE2C", func_8018C5A4); diff --git a/src/ov_SC02_011/ov_SC02_011_o0c.c b/src/ov_SC02_011/ov_SC02_011_o0c.c index de706d674f..619531a53c 100644 --- a/src/ov_SC02_011/ov_SC02_011_o0c.c +++ b/src/ov_SC02_011/ov_SC02_011_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_015/ov_SC02_015.c b/src/ov_SC02_015/ov_SC02_015.c index 1513a4f219..28bbb3c61b 100644 --- a/src/ov_SC02_015/ov_SC02_015.c +++ b/src/ov_SC02_015/ov_SC02_015.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_015/ov_SC02_015_after.c b/src/ov_SC02_015/ov_SC02_015_after.c index 43fc7c90dd..e5e829c2cc 100644 --- a/src/ov_SC02_015/ov_SC02_015_after.c +++ b/src/ov_SC02_015/ov_SC02_015_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_015/ov_SC02_015_jr_8012ACE0.c b/src/ov_SC02_015/ov_SC02_015_jr_8012ACE0.c index 402bd00839..ce90b1d36e 100644 --- a/src/ov_SC02_015/ov_SC02_015_jr_8012ACE0.c +++ b/src/ov_SC02_015/ov_SC02_015_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_015/ov_SC02_015_jr_80135D20.c b/src/ov_SC02_015/ov_SC02_015_jr_80135D20.c index b65c158b3b..2e023d0d19 100644 --- a/src/ov_SC02_015/ov_SC02_015_jr_80135D20.c +++ b/src/ov_SC02_015/ov_SC02_015_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_015/ov_SC02_015_jr_801380E0.c b/src/ov_SC02_015/ov_SC02_015_jr_801380E0.c index 8bf8b83a17..6c66b3d851 100644 --- a/src/ov_SC02_015/ov_SC02_015_jr_801380E0.c +++ b/src/ov_SC02_015/ov_SC02_015_jr_801380E0.c @@ -1101,43 +1101,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 d9d4599471..52f9c02f1b 100644 --- a/src/ov_SC02_015/ov_SC02_015_jr_8015AE2C.c +++ b/src/ov_SC02_015/ov_SC02_015_jr_8015AE2C.c @@ -1814,20 +1814,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_015/ov_SC02_015_jr_8015C32C.c b/src/ov_SC02_015/ov_SC02_015_jr_8015C32C.c index 6fd26c4738..9fef2f6a6d 100644 --- a/src/ov_SC02_015/ov_SC02_015_jr_8015C32C.c +++ b/src/ov_SC02_015/ov_SC02_015_jr_8015C32C.c @@ -3352,31 +3352,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3501,58 +3477,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4188,21 +4113,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4278,51 +4189,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5392,25 +5259,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_015/ov_SC02_015_jr_8016AB6C.c b/src/ov_SC02_015/ov_SC02_015_jr_8016AB6C.c index 729ddaf17e..ce704978a5 100644 --- a/src/ov_SC02_015/ov_SC02_015_jr_8016AB6C.c +++ b/src/ov_SC02_015/ov_SC02_015_jr_8016AB6C.c @@ -2553,21 +2553,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3890,37 +3876,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4285,26 +4241,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4356,38 +4293,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_015/ov_SC02_015_jr_80171B4C.c b/src/ov_SC02_015/ov_SC02_015_jr_80171B4C.c index 2923a5126b..55e6473dd7 100644 --- a/src/ov_SC02_015/ov_SC02_015_jr_80171B4C.c +++ b/src/ov_SC02_015/ov_SC02_015_jr_80171B4C.c @@ -2421,14 +2421,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2545,18 +2538,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_015/ov_SC02_015_jr_801734BC.c b/src/ov_SC02_015/ov_SC02_015_jr_801734BC.c index 4d0421bb6a..37c106ee0a 100644 --- a/src/ov_SC02_015/ov_SC02_015_jr_801734BC.c +++ b/src/ov_SC02_015/ov_SC02_015_jr_801734BC.c @@ -2411,40 +2411,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2617,49 +2584,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2859,38 +2784,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2900,44 +2794,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3728,41 +3585,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_015/ov_SC02_015_o0c.c b/src/ov_SC02_015/ov_SC02_015_o0c.c index fd7c881650..d8f8fdfefe 100644 --- a/src/ov_SC02_015/ov_SC02_015_o0c.c +++ b/src/ov_SC02_015/ov_SC02_015_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_016/ov_SC02_016.c b/src/ov_SC02_016/ov_SC02_016.c index 35eec31445..731eb2f46d 100644 --- a/src/ov_SC02_016/ov_SC02_016.c +++ b/src/ov_SC02_016/ov_SC02_016.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_016/ov_SC02_016_after.c b/src/ov_SC02_016/ov_SC02_016_after.c index 245be954b5..439d68986b 100644 --- a/src/ov_SC02_016/ov_SC02_016_after.c +++ b/src/ov_SC02_016/ov_SC02_016_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_016/ov_SC02_016_jr_8012ACE0.c b/src/ov_SC02_016/ov_SC02_016_jr_8012ACE0.c index 51952faac6..0b50222f41 100644 --- a/src/ov_SC02_016/ov_SC02_016_jr_8012ACE0.c +++ b/src/ov_SC02_016/ov_SC02_016_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_016/ov_SC02_016_jr_80135D20.c b/src/ov_SC02_016/ov_SC02_016_jr_80135D20.c index 83d2f1415c..098d9bc825 100644 --- a/src/ov_SC02_016/ov_SC02_016_jr_80135D20.c +++ b/src/ov_SC02_016/ov_SC02_016_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_016/ov_SC02_016_jr_801380E0.c b/src/ov_SC02_016/ov_SC02_016_jr_801380E0.c index 805c16a9b4..f7f76a099d 100644 --- a/src/ov_SC02_016/ov_SC02_016_jr_801380E0.c +++ b/src/ov_SC02_016/ov_SC02_016_jr_801380E0.c @@ -1101,43 +1101,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 a53c13d476..633e70c64e 100644 --- a/src/ov_SC02_016/ov_SC02_016_jr_8015AE2C.c +++ b/src/ov_SC02_016/ov_SC02_016_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_016/ov_SC02_016_jr_8015C32C.c b/src/ov_SC02_016/ov_SC02_016_jr_8015C32C.c index d042d1898c..c3a07b6469 100644 --- a/src/ov_SC02_016/ov_SC02_016_jr_8015C32C.c +++ b/src/ov_SC02_016/ov_SC02_016_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_016/ov_SC02_016_jr_8016AB6C.c b/src/ov_SC02_016/ov_SC02_016_jr_8016AB6C.c index d2cc05095f..b68b98d675 100644 --- a/src/ov_SC02_016/ov_SC02_016_jr_8016AB6C.c +++ b/src/ov_SC02_016/ov_SC02_016_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_016/ov_SC02_016_jr_80171B4C.c b/src/ov_SC02_016/ov_SC02_016_jr_80171B4C.c index e22177825d..fd1f3cddab 100644 --- a/src/ov_SC02_016/ov_SC02_016_jr_80171B4C.c +++ b/src/ov_SC02_016/ov_SC02_016_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_016/ov_SC02_016_jr_801734BC.c b/src/ov_SC02_016/ov_SC02_016_jr_801734BC.c index 3375ae84ed..992e813b87 100644 --- a/src/ov_SC02_016/ov_SC02_016_jr_801734BC.c +++ b/src/ov_SC02_016/ov_SC02_016_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_016/ov_SC02_016_o0c.c b/src/ov_SC02_016/ov_SC02_016_o0c.c index 7bc683ae4a..1b521c319b 100644 --- a/src/ov_SC02_016/ov_SC02_016_o0c.c +++ b/src/ov_SC02_016/ov_SC02_016_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_017/ov_SC02_017.c b/src/ov_SC02_017/ov_SC02_017.c index 3852307f34..87725a9b96 100644 --- a/src/ov_SC02_017/ov_SC02_017.c +++ b/src/ov_SC02_017/ov_SC02_017.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_017/ov_SC02_017_after.c b/src/ov_SC02_017/ov_SC02_017_after.c index cd0f7001f4..a78a820b2b 100644 --- a/src/ov_SC02_017/ov_SC02_017_after.c +++ b/src/ov_SC02_017/ov_SC02_017_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_017/ov_SC02_017_jr_8012ACE0.c b/src/ov_SC02_017/ov_SC02_017_jr_8012ACE0.c index 1eb455b0d6..0d703c1c68 100644 --- a/src/ov_SC02_017/ov_SC02_017_jr_8012ACE0.c +++ b/src/ov_SC02_017/ov_SC02_017_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_017/ov_SC02_017_jr_80135D20.c b/src/ov_SC02_017/ov_SC02_017_jr_80135D20.c index 06fb96aaaf..4f689170d5 100644 --- a/src/ov_SC02_017/ov_SC02_017_jr_80135D20.c +++ b/src/ov_SC02_017/ov_SC02_017_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_017/ov_SC02_017_jr_801380E0.c b/src/ov_SC02_017/ov_SC02_017_jr_801380E0.c index 094d8dde91..99e1a42264 100644 --- a/src/ov_SC02_017/ov_SC02_017_jr_801380E0.c +++ b/src/ov_SC02_017/ov_SC02_017_jr_801380E0.c @@ -1101,43 +1101,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 ed6a9ac849..ac83e0a070 100644 --- a/src/ov_SC02_017/ov_SC02_017_jr_8015AE2C.c +++ b/src/ov_SC02_017/ov_SC02_017_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_017/ov_SC02_017_jr_8015C32C.c b/src/ov_SC02_017/ov_SC02_017_jr_8015C32C.c index 99e6731cea..368ffb6fdc 100644 --- a/src/ov_SC02_017/ov_SC02_017_jr_8015C32C.c +++ b/src/ov_SC02_017/ov_SC02_017_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_017/ov_SC02_017_jr_8016AB6C.c b/src/ov_SC02_017/ov_SC02_017_jr_8016AB6C.c index 69a8b01a57..217ce0d047 100644 --- a/src/ov_SC02_017/ov_SC02_017_jr_8016AB6C.c +++ b/src/ov_SC02_017/ov_SC02_017_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_017/ov_SC02_017_jr_80171B4C.c b/src/ov_SC02_017/ov_SC02_017_jr_80171B4C.c index 713eda50b5..14835a6ada 100644 --- a/src/ov_SC02_017/ov_SC02_017_jr_80171B4C.c +++ b/src/ov_SC02_017/ov_SC02_017_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_017/ov_SC02_017_jr_801734BC.c b/src/ov_SC02_017/ov_SC02_017_jr_801734BC.c index b50160c35a..cb22868cd1 100644 --- a/src/ov_SC02_017/ov_SC02_017_jr_801734BC.c +++ b/src/ov_SC02_017/ov_SC02_017_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_017/ov_SC02_017_o0c.c b/src/ov_SC02_017/ov_SC02_017_o0c.c index e5e3ad0bad..8497133630 100644 --- a/src/ov_SC02_017/ov_SC02_017_o0c.c +++ b/src/ov_SC02_017/ov_SC02_017_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_021/ov_SC02_021.c b/src/ov_SC02_021/ov_SC02_021.c index 6696f143da..ab6cb644b2 100644 --- a/src/ov_SC02_021/ov_SC02_021.c +++ b/src/ov_SC02_021/ov_SC02_021.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_021/ov_SC02_021_after.c b/src/ov_SC02_021/ov_SC02_021_after.c index d15f0ec599..6d0c7e569a 100644 --- a/src/ov_SC02_021/ov_SC02_021_after.c +++ b/src/ov_SC02_021/ov_SC02_021_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_021/ov_SC02_021_jr_8012ACE0.c b/src/ov_SC02_021/ov_SC02_021_jr_8012ACE0.c index 8d0aa17c98..3b3d54f736 100644 --- a/src/ov_SC02_021/ov_SC02_021_jr_8012ACE0.c +++ b/src/ov_SC02_021/ov_SC02_021_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_021/ov_SC02_021_jr_80135D20.c b/src/ov_SC02_021/ov_SC02_021_jr_80135D20.c index b8abf78b58..c4e4723d43 100644 --- a/src/ov_SC02_021/ov_SC02_021_jr_80135D20.c +++ b/src/ov_SC02_021/ov_SC02_021_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_021/ov_SC02_021_jr_801380E0.c b/src/ov_SC02_021/ov_SC02_021_jr_801380E0.c index 576771ec1c..59a7d7a21f 100644 --- a/src/ov_SC02_021/ov_SC02_021_jr_801380E0.c +++ b/src/ov_SC02_021/ov_SC02_021_jr_801380E0.c @@ -1101,43 +1101,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 15f5337258..aaa0537a63 100644 --- a/src/ov_SC02_021/ov_SC02_021_jr_8015AE2C.c +++ b/src/ov_SC02_021/ov_SC02_021_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_021/ov_SC02_021_jr_8015C32C.c b/src/ov_SC02_021/ov_SC02_021_jr_8015C32C.c index b494b361c0..7d4a54358e 100644 --- a/src/ov_SC02_021/ov_SC02_021_jr_8015C32C.c +++ b/src/ov_SC02_021/ov_SC02_021_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_021/ov_SC02_021_jr_8016AB6C.c b/src/ov_SC02_021/ov_SC02_021_jr_8016AB6C.c index f32c2430b2..b41b0335e8 100644 --- a/src/ov_SC02_021/ov_SC02_021_jr_8016AB6C.c +++ b/src/ov_SC02_021/ov_SC02_021_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_021/ov_SC02_021_jr_80171B4C.c b/src/ov_SC02_021/ov_SC02_021_jr_80171B4C.c index da9e6a4e41..93783c6e77 100644 --- a/src/ov_SC02_021/ov_SC02_021_jr_80171B4C.c +++ b/src/ov_SC02_021/ov_SC02_021_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_021/ov_SC02_021_jr_801734BC.c b/src/ov_SC02_021/ov_SC02_021_jr_801734BC.c index 13f3003245..e2a09f88be 100644 --- a/src/ov_SC02_021/ov_SC02_021_jr_801734BC.c +++ b/src/ov_SC02_021/ov_SC02_021_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_021/ov_SC02_021_o0c.c b/src/ov_SC02_021/ov_SC02_021_o0c.c index 151b30c3d5..332b31a495 100644 --- a/src/ov_SC02_021/ov_SC02_021_o0c.c +++ b/src/ov_SC02_021/ov_SC02_021_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_026/ov_SC02_026.c b/src/ov_SC02_026/ov_SC02_026.c index d043ad3e9a..8375666dd5 100644 --- a/src/ov_SC02_026/ov_SC02_026.c +++ b/src/ov_SC02_026/ov_SC02_026.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_026/ov_SC02_026_after.c b/src/ov_SC02_026/ov_SC02_026_after.c index a146f39ce5..a1e83261f5 100644 --- a/src/ov_SC02_026/ov_SC02_026_after.c +++ b/src/ov_SC02_026/ov_SC02_026_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_026/ov_SC02_026_jr_8012ACE0.c b/src/ov_SC02_026/ov_SC02_026_jr_8012ACE0.c index 9a250e07b3..30b1e27906 100644 --- a/src/ov_SC02_026/ov_SC02_026_jr_8012ACE0.c +++ b/src/ov_SC02_026/ov_SC02_026_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_026/ov_SC02_026_jr_80135D20.c b/src/ov_SC02_026/ov_SC02_026_jr_80135D20.c index c824173ad9..6f9cd23e58 100644 --- a/src/ov_SC02_026/ov_SC02_026_jr_80135D20.c +++ b/src/ov_SC02_026/ov_SC02_026_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_026/ov_SC02_026_jr_801380E0.c b/src/ov_SC02_026/ov_SC02_026_jr_801380E0.c index e8f02d111f..850b2f12fc 100644 --- a/src/ov_SC02_026/ov_SC02_026_jr_801380E0.c +++ b/src/ov_SC02_026/ov_SC02_026_jr_801380E0.c @@ -1101,43 +1101,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 17e77d48d8..821e9a71d7 100644 --- a/src/ov_SC02_026/ov_SC02_026_jr_8015AE2C.c +++ b/src/ov_SC02_026/ov_SC02_026_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_026/ov_SC02_026_jr_8015C32C.c b/src/ov_SC02_026/ov_SC02_026_jr_8015C32C.c index c7310faa53..f1ec675f57 100644 --- a/src/ov_SC02_026/ov_SC02_026_jr_8015C32C.c +++ b/src/ov_SC02_026/ov_SC02_026_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_026/ov_SC02_026_jr_8016AB6C.c b/src/ov_SC02_026/ov_SC02_026_jr_8016AB6C.c index 0f62927262..8dbdd6c9ec 100644 --- a/src/ov_SC02_026/ov_SC02_026_jr_8016AB6C.c +++ b/src/ov_SC02_026/ov_SC02_026_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_026/ov_SC02_026_jr_80171B4C.c b/src/ov_SC02_026/ov_SC02_026_jr_80171B4C.c index bbe649e607..d2e6b8ce56 100644 --- a/src/ov_SC02_026/ov_SC02_026_jr_80171B4C.c +++ b/src/ov_SC02_026/ov_SC02_026_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_026/ov_SC02_026_jr_801734BC.c b/src/ov_SC02_026/ov_SC02_026_jr_801734BC.c index 279780cc19..e367812ac1 100644 --- a/src/ov_SC02_026/ov_SC02_026_jr_801734BC.c +++ b/src/ov_SC02_026/ov_SC02_026_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_026/ov_SC02_026_o0c.c b/src/ov_SC02_026/ov_SC02_026_o0c.c index e0bca299f4..bed692ae7b 100644 --- a/src/ov_SC02_026/ov_SC02_026_o0c.c +++ b/src/ov_SC02_026/ov_SC02_026_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_027/ov_SC02_027.c b/src/ov_SC02_027/ov_SC02_027.c index 0e4320a436..f446066c1a 100644 --- a/src/ov_SC02_027/ov_SC02_027.c +++ b/src/ov_SC02_027/ov_SC02_027.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_027/ov_SC02_027_after.c b/src/ov_SC02_027/ov_SC02_027_after.c index 9a44266ba4..eb3b68f93e 100644 --- a/src/ov_SC02_027/ov_SC02_027_after.c +++ b/src/ov_SC02_027/ov_SC02_027_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_027/ov_SC02_027_jr_8012ACE0.c b/src/ov_SC02_027/ov_SC02_027_jr_8012ACE0.c index 24b2b50d13..4d30cbecd4 100644 --- a/src/ov_SC02_027/ov_SC02_027_jr_8012ACE0.c +++ b/src/ov_SC02_027/ov_SC02_027_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_027/ov_SC02_027_jr_80135D20.c b/src/ov_SC02_027/ov_SC02_027_jr_80135D20.c index f650012f8d..fcac6e353e 100644 --- a/src/ov_SC02_027/ov_SC02_027_jr_80135D20.c +++ b/src/ov_SC02_027/ov_SC02_027_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_027/ov_SC02_027_jr_801380E0.c b/src/ov_SC02_027/ov_SC02_027_jr_801380E0.c index 9e406ef95f..6f502350a2 100644 --- a/src/ov_SC02_027/ov_SC02_027_jr_801380E0.c +++ b/src/ov_SC02_027/ov_SC02_027_jr_801380E0.c @@ -1101,43 +1101,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 c02b735256..00e11a8979 100644 --- a/src/ov_SC02_027/ov_SC02_027_jr_8015AE2C.c +++ b/src/ov_SC02_027/ov_SC02_027_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_027/ov_SC02_027_jr_8015C32C.c b/src/ov_SC02_027/ov_SC02_027_jr_8015C32C.c index 9d8ffd32a6..f6f629a02d 100644 --- a/src/ov_SC02_027/ov_SC02_027_jr_8015C32C.c +++ b/src/ov_SC02_027/ov_SC02_027_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_027/ov_SC02_027_jr_8016AB6C.c b/src/ov_SC02_027/ov_SC02_027_jr_8016AB6C.c index 668af6ecee..c4cbfc451c 100644 --- a/src/ov_SC02_027/ov_SC02_027_jr_8016AB6C.c +++ b/src/ov_SC02_027/ov_SC02_027_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_027/ov_SC02_027_jr_80171B4C.c b/src/ov_SC02_027/ov_SC02_027_jr_80171B4C.c index 57151ef67b..bf28e6036e 100644 --- a/src/ov_SC02_027/ov_SC02_027_jr_80171B4C.c +++ b/src/ov_SC02_027/ov_SC02_027_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_027/ov_SC02_027_jr_801734BC.c b/src/ov_SC02_027/ov_SC02_027_jr_801734BC.c index 93b6b98322..3db3850a96 100644 --- a/src/ov_SC02_027/ov_SC02_027_jr_801734BC.c +++ b/src/ov_SC02_027/ov_SC02_027_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_027/ov_SC02_027_o0c.c b/src/ov_SC02_027/ov_SC02_027_o0c.c index 358b5b1b6c..2f6f7516a6 100644 --- a/src/ov_SC02_027/ov_SC02_027_o0c.c +++ b/src/ov_SC02_027/ov_SC02_027_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_028/ov_SC02_028.c b/src/ov_SC02_028/ov_SC02_028.c index 324d9de231..19ea2e526f 100644 --- a/src/ov_SC02_028/ov_SC02_028.c +++ b/src/ov_SC02_028/ov_SC02_028.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_028/ov_SC02_028_after.c b/src/ov_SC02_028/ov_SC02_028_after.c index 8063def446..8d749f9433 100644 --- a/src/ov_SC02_028/ov_SC02_028_after.c +++ b/src/ov_SC02_028/ov_SC02_028_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_028/ov_SC02_028_jr_8012ACE0.c b/src/ov_SC02_028/ov_SC02_028_jr_8012ACE0.c index 47957ab2ae..c264e79dff 100644 --- a/src/ov_SC02_028/ov_SC02_028_jr_8012ACE0.c +++ b/src/ov_SC02_028/ov_SC02_028_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_028/ov_SC02_028_jr_80135D20.c b/src/ov_SC02_028/ov_SC02_028_jr_80135D20.c index 88a63732d3..de7692be2f 100644 --- a/src/ov_SC02_028/ov_SC02_028_jr_80135D20.c +++ b/src/ov_SC02_028/ov_SC02_028_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_028/ov_SC02_028_jr_801380E0.c b/src/ov_SC02_028/ov_SC02_028_jr_801380E0.c index 2076b29d22..6bccd5f1a5 100644 --- a/src/ov_SC02_028/ov_SC02_028_jr_801380E0.c +++ b/src/ov_SC02_028/ov_SC02_028_jr_801380E0.c @@ -1101,43 +1101,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 34d95f3c9d..622a2a67f1 100644 --- a/src/ov_SC02_028/ov_SC02_028_jr_8015AE2C.c +++ b/src/ov_SC02_028/ov_SC02_028_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_028/ov_SC02_028_jr_8015C32C.c b/src/ov_SC02_028/ov_SC02_028_jr_8015C32C.c index a6da7e40d5..1f82d4d038 100644 --- a/src/ov_SC02_028/ov_SC02_028_jr_8015C32C.c +++ b/src/ov_SC02_028/ov_SC02_028_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_028/ov_SC02_028_jr_8016AB6C.c b/src/ov_SC02_028/ov_SC02_028_jr_8016AB6C.c index 7fa8fc6734..208f6580e6 100644 --- a/src/ov_SC02_028/ov_SC02_028_jr_8016AB6C.c +++ b/src/ov_SC02_028/ov_SC02_028_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_028/ov_SC02_028_jr_80171B4C.c b/src/ov_SC02_028/ov_SC02_028_jr_80171B4C.c index 3da534c8ab..8c570beaed 100644 --- a/src/ov_SC02_028/ov_SC02_028_jr_80171B4C.c +++ b/src/ov_SC02_028/ov_SC02_028_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_028/ov_SC02_028_jr_801734BC.c b/src/ov_SC02_028/ov_SC02_028_jr_801734BC.c index 6c73db4c3e..efe0c9a6f5 100644 --- a/src/ov_SC02_028/ov_SC02_028_jr_801734BC.c +++ b/src/ov_SC02_028/ov_SC02_028_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_028/ov_SC02_028_o0c.c b/src/ov_SC02_028/ov_SC02_028_o0c.c index 8157ae280d..5bdbcca1c6 100644 --- a/src/ov_SC02_028/ov_SC02_028_o0c.c +++ b/src/ov_SC02_028/ov_SC02_028_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_031/ov_SC02_031.c b/src/ov_SC02_031/ov_SC02_031.c index 35fe956e84..b02b41e33e 100644 --- a/src/ov_SC02_031/ov_SC02_031.c +++ b/src/ov_SC02_031/ov_SC02_031.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_031/ov_SC02_031_after.c b/src/ov_SC02_031/ov_SC02_031_after.c index 9c17504dbb..aa6581e22b 100644 --- a/src/ov_SC02_031/ov_SC02_031_after.c +++ b/src/ov_SC02_031/ov_SC02_031_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_031/ov_SC02_031_jr_8012ACE0.c b/src/ov_SC02_031/ov_SC02_031_jr_8012ACE0.c index 5d97f8b6a2..9ca6ed80f2 100644 --- a/src/ov_SC02_031/ov_SC02_031_jr_8012ACE0.c +++ b/src/ov_SC02_031/ov_SC02_031_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_031/ov_SC02_031_jr_80135D20.c b/src/ov_SC02_031/ov_SC02_031_jr_80135D20.c index 8710c612d8..a994eab32f 100644 --- a/src/ov_SC02_031/ov_SC02_031_jr_80135D20.c +++ b/src/ov_SC02_031/ov_SC02_031_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_031/ov_SC02_031_jr_801380E0.c b/src/ov_SC02_031/ov_SC02_031_jr_801380E0.c index 02f451ab3b..56954b4c72 100644 --- a/src/ov_SC02_031/ov_SC02_031_jr_801380E0.c +++ b/src/ov_SC02_031/ov_SC02_031_jr_801380E0.c @@ -1101,43 +1101,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 4143afe5f7..6d17005a86 100644 --- a/src/ov_SC02_031/ov_SC02_031_jr_8015AE2C.c +++ b/src/ov_SC02_031/ov_SC02_031_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_031/ov_SC02_031_jr_8015C32C.c b/src/ov_SC02_031/ov_SC02_031_jr_8015C32C.c index eb3e0b5d12..0c710caef9 100644 --- a/src/ov_SC02_031/ov_SC02_031_jr_8015C32C.c +++ b/src/ov_SC02_031/ov_SC02_031_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_031/ov_SC02_031_jr_8016AB6C.c b/src/ov_SC02_031/ov_SC02_031_jr_8016AB6C.c index d08ef25e27..637a59df7a 100644 --- a/src/ov_SC02_031/ov_SC02_031_jr_8016AB6C.c +++ b/src/ov_SC02_031/ov_SC02_031_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_031/ov_SC02_031_jr_80171B4C.c b/src/ov_SC02_031/ov_SC02_031_jr_80171B4C.c index 1fdefc48d1..081febef08 100644 --- a/src/ov_SC02_031/ov_SC02_031_jr_80171B4C.c +++ b/src/ov_SC02_031/ov_SC02_031_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_031/ov_SC02_031_jr_801734BC.c b/src/ov_SC02_031/ov_SC02_031_jr_801734BC.c index 198c7cdd0f..eb5fecbda3 100644 --- a/src/ov_SC02_031/ov_SC02_031_jr_801734BC.c +++ b/src/ov_SC02_031/ov_SC02_031_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_031/ov_SC02_031_o0c.c b/src/ov_SC02_031/ov_SC02_031_o0c.c index 07819a8f8a..838fb9b042 100644 --- a/src/ov_SC02_031/ov_SC02_031_o0c.c +++ b/src/ov_SC02_031/ov_SC02_031_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_035/ov_SC02_035.c b/src/ov_SC02_035/ov_SC02_035.c index 9950c15644..477751811e 100644 --- a/src/ov_SC02_035/ov_SC02_035.c +++ b/src/ov_SC02_035/ov_SC02_035.c @@ -678,14 +678,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -711,40 +704,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_035/ov_SC02_035_after.c b/src/ov_SC02_035/ov_SC02_035_after.c index 7bb2a1fce6..2a9e059d4b 100644 --- a/src/ov_SC02_035/ov_SC02_035_after.c +++ b/src/ov_SC02_035/ov_SC02_035_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_035/ov_SC02_035_jr_8012ACE0.c b/src/ov_SC02_035/ov_SC02_035_jr_8012ACE0.c index 10782ba413..846760218e 100644 --- a/src/ov_SC02_035/ov_SC02_035_jr_8012ACE0.c +++ b/src/ov_SC02_035/ov_SC02_035_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2552,35 +2416,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_035/ov_SC02_035_jr_80135D20.c b/src/ov_SC02_035/ov_SC02_035_jr_80135D20.c index 2793143ae7..af13514bc6 100644 --- a/src/ov_SC02_035/ov_SC02_035_jr_80135D20.c +++ b/src/ov_SC02_035/ov_SC02_035_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_035/ov_SC02_035_jr_801380E0.c b/src/ov_SC02_035/ov_SC02_035_jr_801380E0.c index bb20f66eb5..8d816e86e6 100644 --- a/src/ov_SC02_035/ov_SC02_035_jr_801380E0.c +++ b/src/ov_SC02_035/ov_SC02_035_jr_801380E0.c @@ -1101,43 +1101,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 b99953b7cd..8e27b8c09a 100644 --- a/src/ov_SC02_035/ov_SC02_035_jr_8015AE2C.c +++ b/src/ov_SC02_035/ov_SC02_035_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_035/ov_SC02_035_jr_8015C32C.c b/src/ov_SC02_035/ov_SC02_035_jr_8015C32C.c index db96c88777..9bf61b56eb 100644 --- a/src/ov_SC02_035/ov_SC02_035_jr_8015C32C.c +++ b/src/ov_SC02_035/ov_SC02_035_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_035/ov_SC02_035_jr_8016AB6C.c b/src/ov_SC02_035/ov_SC02_035_jr_8016AB6C.c index 8b5057dd08..97a33fe171 100644 --- a/src/ov_SC02_035/ov_SC02_035_jr_8016AB6C.c +++ b/src/ov_SC02_035/ov_SC02_035_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_035/ov_SC02_035_jr_80171B4C.c b/src/ov_SC02_035/ov_SC02_035_jr_80171B4C.c index 8cd1fdf871..0d745f16b5 100644 --- a/src/ov_SC02_035/ov_SC02_035_jr_80171B4C.c +++ b/src/ov_SC02_035/ov_SC02_035_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_035/ov_SC02_035_jr_801734BC.c b/src/ov_SC02_035/ov_SC02_035_jr_801734BC.c index 1627fb8be1..5803197004 100644 --- a/src/ov_SC02_035/ov_SC02_035_jr_801734BC.c +++ b/src/ov_SC02_035/ov_SC02_035_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_035/ov_SC02_035_o0c.c b/src/ov_SC02_035/ov_SC02_035_o0c.c index bf29c0ae6a..3bad581f11 100644 --- a/src/ov_SC02_035/ov_SC02_035_o0c.c +++ b/src/ov_SC02_035/ov_SC02_035_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_037/ov_SC02_037.c b/src/ov_SC02_037/ov_SC02_037.c index f9cfe3604e..a1d315712b 100644 --- a/src/ov_SC02_037/ov_SC02_037.c +++ b/src/ov_SC02_037/ov_SC02_037.c @@ -730,14 +730,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129cf8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129ff4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012a048 (src/shared) */ @@ -769,40 +762,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012a110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012a2f4 (src/shared) */ @@ -1111,46 +1071,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012b70c (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012b744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); -extern s32 func_8004787C(s32 a0); - -s32 func_8012B77C(s32 out, s32 a1, s32 a2) -{ - register u32 packed __asm__("$20"); - s32 dz; - s32 dx; - s32 dy; - register s32 t __asm__("$16"); - s32 sn; - s32 cs; - s32 ang; - - packed &= 0xFFFF; - - dz = *(s16 *)((s32)a2 + 0xA) - *(s16 *)((s32)a1 + 0xA); - dx = *(s16 *)((s32)a2 + 0x2) - *(s16 *)((s32)a1 + 0x2); - dy = *(s16 *)((s32)a2 + 0x6) - *(s16 *)((s32)a1 + 0x6); - - ang = ratan2(-dz, dx); - t = ang - 0x400; - t &= 0xFFF; - packed |= (u32)(t << 16); - - sn = func_80047948(t); - cs = func_8004787C(t); - - dz = (dz * sn + dx * cs) >> 12; - ang = ratan2(dy, -dz); - packed &= 0xFFFF0000; - packed |= (u32)(ang & 0xFFFF); - - { - u32 addr; - __asm__("addu %0,%1,$zero" : "=r"(addr) : "r"(out)); - *(u32 *)addr = packed; - } -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012b864 (src/shared) */ @@ -1897,23 +1818,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012ef70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ DEFINE_func_8012F038() /* dedup: shared engine-core @0x8012f038 (src/shared) */ @@ -1946,29 +1851,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012f374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012f49c (src/shared) */ diff --git a/src/ov_SC02_037/ov_SC02_037_jr_80131340.c b/src/ov_SC02_037/ov_SC02_037_jr_80131340.c index 0f0e1cc5eb..651342f95d 100644 --- a/src/ov_SC02_037/ov_SC02_037_jr_80131340.c +++ b/src/ov_SC02_037/ov_SC02_037_jr_80131340.c @@ -869,25 +869,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319e0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131ac8 (src/shared) */ @@ -998,15 +980,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ typedef struct { s8 c[8]; } Blk8_80131CF4; @@ -1039,37 +1013,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131d68 (src/shared) */ @@ -1569,35 +1513,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339c (src/shared) */ diff --git a/src/ov_SC02_037/ov_SC02_037_jr_80135EB0.c b/src/ov_SC02_037/ov_SC02_037_jr_80135EB0.c index 8bf9b41327..d09713e185 100644 --- a/src/ov_SC02_037/ov_SC02_037_jr_80135EB0.c +++ b/src/ov_SC02_037/ov_SC02_037_jr_80135EB0.c @@ -1232,17 +1232,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767c (src/shared) */ @@ -1288,32 +1278,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377b4 (src/shared) */ diff --git a/src/ov_SC02_037/ov_SC02_037_jr_801380E0.c b/src/ov_SC02_037/ov_SC02_037_jr_801380E0.c index af18a59d64..eeda208c22 100644 --- a/src/ov_SC02_037/ov_SC02_037_jr_801380E0.c +++ b/src/ov_SC02_037/ov_SC02_037_jr_801380E0.c @@ -1125,43 +1125,7 @@ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138db8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ed0 (src/shared) */ diff --git a/src/ov_SC02_037/ov_SC02_037_jr_8013F350.c b/src/ov_SC02_037/ov_SC02_037_jr_8013F350.c index f512f78f35..49c2b90058 100644 --- a/src/ov_SC02_037/ov_SC02_037_jr_8013F350.c +++ b/src/ov_SC02_037/ov_SC02_037_jr_8013F350.c @@ -4455,52 +4455,7 @@ void func_80149584(s32 a0, s32 a1, s32 a2) } -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ DEFINE_func_8014964C() /* dedup: shared engine-core @0x8014964c (src/shared) */ @@ -4837,48 +4792,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014a71c (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014a830 (src/shared) */ @@ -5120,38 +5034,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014c43c (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U *)(a0 + 0x7C) = *(V4U *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ DEFINE_func_8014C568() /* dedup: shared engine-core @0x8014c568 (src/shared) */ @@ -5393,64 +5276,7 @@ extern u8 D_80126720[]; s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); s32 func_8014C918(s32 a0, s32 a1); -s32 func_8014D610(s32 a0, s32 a1, u16* a2) -{ - u8 *s1, *s0; - s32 result; - - s1 = D_801202A0; - - if (!(s1 < D_801202A0 + 0x6480)) { - return 0; - } - - s0 = s1 + 0x75; - - while (1) { - if (*(u16*)s1 == 0) { - goto next_iter; - } - - if ((*(u16*)(s0 - 0x19) & 0x400) == 0) { - goto next_iter; - } - - if (*(s32*)(s0 - 0x1D) == 0) { - goto next_iter; - } - - if (*(s16*)(s0 - 0x6B) < *(s16*)(a0 + 10)) { - goto next_iter; - } - - result = func_80135A4C(*(s32*)(s0 - 0x55), *(s32*)(s0 - 0x1D), a1, (s32)a2); - - if (result == 0) { - goto next_iter; - } - - *(u8**)(a0 + 0x174) = s1; - *(u8*)(s0 - 1) = 1; - - *(u16*)(a0 + 6) = a2[0]; - *(u16*)(a0 + 10) = a2[1]; - *(u16*)(a0 + 14) = a2[2]; - - result = func_8014C918((s32)a0, *(u8*)s0); - - *(u16*)(a0 + 0x16E) = result & 0xFF; - - return 1; - - next_iter: - s1 = s1 + 0x10C; - s0 = s0 + 0x10C; - - if (!(s1 < D_80126720)) { - return 0; - } - } -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -5974,40 +5800,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_037/ov_SC02_037_jr_8015A3C8.c b/src/ov_SC02_037/ov_SC02_037_jr_8015A3C8.c index 996c9bcbe1..c7f100a51c 100644 --- a/src/ov_SC02_037/ov_SC02_037_jr_8015A3C8.c +++ b/src/ov_SC02_037/ov_SC02_037_jr_8015A3C8.c @@ -3119,20 +3119,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015c08c (src/shared) */ @@ -5468,37 +5455,7 @@ void func_8015BDD0(s32 *a0); void func_8015BF48(s32 *a0); void func_80015954(s32 a0, s32 a1); -int func_80161374(int a0, unsigned a1) -{ - s32 s0 = (s32)a0; - s32 v0; - - if (a1 == 0 || a1 == 0x8000) { - func_801599A4(a0); - func_8015BDD0((s32 *)a0); - return 1; - } - - if ((a1 & 0x4000) == 0) { - return 0; - } - - v0 = D_801152BC; - if (v0 != 0) { - func_801599A4(a0); - func_8015BF48((s32 *)a0); - return 1; - } - - if (*(s16 *)(s0 + 0xA) < *(s16 *)(s0 + 0x8A)) { - func_80015954(s0 + 0x88, s0 + 0x4); - return 0; - } - - func_801599A4(a0); - func_8015BF48((s32 *)a0); - return 1; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -5537,61 +5494,7 @@ void func_80161D20(s32 a0, s32 a1); DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); -extern s32 func_8016163C(s32 a0, u32 a1); -extern s32 func_80161774(int a0, u32 a1); -extern s32 func_80161888(s32 a0, u32 a1); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197c (src/shared) */ @@ -6308,51 +6211,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ diff --git a/src/ov_SC02_037/ov_SC02_037_jr_8016AE5C.c b/src/ov_SC02_037/ov_SC02_037_jr_8016AE5C.c index 68722e68c5..1145e3b831 100644 --- a/src/ov_SC02_037/ov_SC02_037_jr_8016AE5C.c +++ b/src/ov_SC02_037/ov_SC02_037_jr_8016AE5C.c @@ -3410,21 +3410,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016bf34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -4749,37 +4735,7 @@ void func_8016F0AC(void) { * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016f14c (src/shared) */ @@ -5249,26 +5205,7 @@ DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084c (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -5335,38 +5272,7 @@ DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170cb0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_037/ov_SC02_037_jr_80171B4C.c b/src/ov_SC02_037/ov_SC02_037_jr_80171B4C.c index f5f054e3f6..77c3e3a835 100644 --- a/src/ov_SC02_037/ov_SC02_037_jr_80171B4C.c +++ b/src/ov_SC02_037/ov_SC02_037_jr_80171B4C.c @@ -3475,14 +3475,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172bc8 (src/shared) */ void func_80172C48(void) { } -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -3615,14 +3608,7 @@ void func_801734BC(s32 a0, s32 a1); typedef struct { u32 a; u32 b; } __attribute__((packed, aligned(1))) Unaligned8; -void func_801733FC(s32 a0, s32 a1) -{ - func_801734BC(a0, a1); - - *(Unaligned8 *)&D_80126B38 = *(Unaligned8 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ @@ -3725,40 +3711,7 @@ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173a28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) -{ - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -3939,49 +3892,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749a8 (src/shared) */ // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - - extern u16 D_80126B5E; - extern u16 D_80126B62; - extern u16 D_80126B66; - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174b6c (src/shared) */ @@ -4191,53 +4102,7 @@ DEFINE_func_801757A0() /* dedup: shared engine-core @0x801757a0 (src/shared) */ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757e0 (src/shared) */ -extern s32 func_801758FC(void); - -/* func_80175820 — twin of the byte-matched func_801759D8 / func_801758FC in this same TU - * (ov_SC01_077_jr_801734BC). Same three-part body, different slot: - * part 1 tag word = ptr[2] (0x8 vs 0x4 / 0xC) - * part 2 head ptr = D_8011F7A8+0x18 (== D_8011F7C0) - * part 3 tail ptr = D_8011F7A8+0x20 (== D_8011F7C8) - * The two __asm__ memory fences are what keep the three parts from CSE-ing their - * base addresses together (parts 1/2 stay absolute lui/%lo + idx*4; part 3 keeps the - * shared `la $v1,D_8011F7A8` + 0x18/0x20 displacements). - */ - - /* size 0x14 */ - /* size 0x0C */ - -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820 D_800AE7BC[]; - extern S_AF634_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758fc (src/shared) */ @@ -4249,44 +4114,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758fc (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -5059,41 +4887,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777bc (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_039/ov_SC02_039.c b/src/ov_SC02_039/ov_SC02_039.c index 1c61f67c8f..ec2b3bbf8e 100644 --- a/src/ov_SC02_039/ov_SC02_039.c +++ b/src/ov_SC02_039/ov_SC02_039.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_039/ov_SC02_039_after.c b/src/ov_SC02_039/ov_SC02_039_after.c index 0ce634911a..6e326a4c53 100644 --- a/src/ov_SC02_039/ov_SC02_039_after.c +++ b/src/ov_SC02_039/ov_SC02_039_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_039/ov_SC02_039_jr_8012ACE0.c b/src/ov_SC02_039/ov_SC02_039_jr_8012ACE0.c index ec34dd0930..7e24e57bf3 100644 --- a/src/ov_SC02_039/ov_SC02_039_jr_8012ACE0.c +++ b/src/ov_SC02_039/ov_SC02_039_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_039/ov_SC02_039_jr_80135D20.c b/src/ov_SC02_039/ov_SC02_039_jr_80135D20.c index e4f778b56e..6ef8df7cbc 100644 --- a/src/ov_SC02_039/ov_SC02_039_jr_80135D20.c +++ b/src/ov_SC02_039/ov_SC02_039_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_039/ov_SC02_039_jr_801380E0.c b/src/ov_SC02_039/ov_SC02_039_jr_801380E0.c index a1a333f0ea..b8371ddfe4 100644 --- a/src/ov_SC02_039/ov_SC02_039_jr_801380E0.c +++ b/src/ov_SC02_039/ov_SC02_039_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 c83ad32990..de70b734eb 100644 --- a/src/ov_SC02_039/ov_SC02_039_jr_8015AE2C.c +++ b/src/ov_SC02_039/ov_SC02_039_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_039/ov_SC02_039_jr_8015C32C.c b/src/ov_SC02_039/ov_SC02_039_jr_8015C32C.c index ba00013627..caf382bdbf 100644 --- a/src/ov_SC02_039/ov_SC02_039_jr_8015C32C.c +++ b/src/ov_SC02_039/ov_SC02_039_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_039/ov_SC02_039_jr_8016AB6C.c b/src/ov_SC02_039/ov_SC02_039_jr_8016AB6C.c index 923dd4676d..d257cc0e32 100644 --- a/src/ov_SC02_039/ov_SC02_039_jr_8016AB6C.c +++ b/src/ov_SC02_039/ov_SC02_039_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_039/ov_SC02_039_jr_80171B4C.c b/src/ov_SC02_039/ov_SC02_039_jr_80171B4C.c index 29b9bfa796..5a27b6a2b6 100644 --- a/src/ov_SC02_039/ov_SC02_039_jr_80171B4C.c +++ b/src/ov_SC02_039/ov_SC02_039_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_039/ov_SC02_039_jr_801734BC.c b/src/ov_SC02_039/ov_SC02_039_jr_801734BC.c index d4bb091c98..fb1350dc5f 100644 --- a/src/ov_SC02_039/ov_SC02_039_jr_801734BC.c +++ b/src/ov_SC02_039/ov_SC02_039_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_039/ov_SC02_039_o0c.c b/src/ov_SC02_039/ov_SC02_039_o0c.c index e98c31922c..e5afcb9e9f 100644 --- a/src/ov_SC02_039/ov_SC02_039_o0c.c +++ b/src/ov_SC02_039/ov_SC02_039_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC02_041/ov_SC02_041.c b/src/ov_SC02_041/ov_SC02_041.c index 72df117dda..ec3463941f 100644 --- a/src/ov_SC02_041/ov_SC02_041.c +++ b/src/ov_SC02_041/ov_SC02_041.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC02_041/ov_SC02_041_after.c b/src/ov_SC02_041/ov_SC02_041_after.c index 333829078b..692c40ed20 100644 --- a/src/ov_SC02_041/ov_SC02_041_after.c +++ b/src/ov_SC02_041/ov_SC02_041_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC02_041/ov_SC02_041_jr_8012ACE0.c b/src/ov_SC02_041/ov_SC02_041_jr_8012ACE0.c index c98cb8c5e8..55e5105182 100644 --- a/src/ov_SC02_041/ov_SC02_041_jr_8012ACE0.c +++ b/src/ov_SC02_041/ov_SC02_041_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC02_041/ov_SC02_041_jr_80135D20.c b/src/ov_SC02_041/ov_SC02_041_jr_80135D20.c index 7b02027ab0..187c874a3b 100644 --- a/src/ov_SC02_041/ov_SC02_041_jr_80135D20.c +++ b/src/ov_SC02_041/ov_SC02_041_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC02_041/ov_SC02_041_jr_801380E0.c b/src/ov_SC02_041/ov_SC02_041_jr_801380E0.c index 8b9e6bde03..3a39046986 100644 --- a/src/ov_SC02_041/ov_SC02_041_jr_801380E0.c +++ b/src/ov_SC02_041/ov_SC02_041_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 a910c85575..7e1f57b3bc 100644 --- a/src/ov_SC02_041/ov_SC02_041_jr_8015AE2C.c +++ b/src/ov_SC02_041/ov_SC02_041_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC02_041/ov_SC02_041_jr_8015C32C.c b/src/ov_SC02_041/ov_SC02_041_jr_8015C32C.c index b174a75ae0..d817ae1c56 100644 --- a/src/ov_SC02_041/ov_SC02_041_jr_8015C32C.c +++ b/src/ov_SC02_041/ov_SC02_041_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC02_041/ov_SC02_041_jr_8016AB6C.c b/src/ov_SC02_041/ov_SC02_041_jr_8016AB6C.c index fc50ba2340..10093358a6 100644 --- a/src/ov_SC02_041/ov_SC02_041_jr_8016AB6C.c +++ b/src/ov_SC02_041/ov_SC02_041_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC02_041/ov_SC02_041_jr_80171B4C.c b/src/ov_SC02_041/ov_SC02_041_jr_80171B4C.c index e96d86ada3..193c54f560 100644 --- a/src/ov_SC02_041/ov_SC02_041_jr_80171B4C.c +++ b/src/ov_SC02_041/ov_SC02_041_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC02_041/ov_SC02_041_jr_801734BC.c b/src/ov_SC02_041/ov_SC02_041_jr_801734BC.c index 33f200c9fc..a990253031 100644 --- a/src/ov_SC02_041/ov_SC02_041_jr_801734BC.c +++ b/src/ov_SC02_041/ov_SC02_041_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC02_041/ov_SC02_041_o0c.c b/src/ov_SC02_041/ov_SC02_041_o0c.c index 075c7a5a0e..2a5223b9af 100644 --- a/src/ov_SC02_041/ov_SC02_041_o0c.c +++ b/src/ov_SC02_041/ov_SC02_041_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_001/ov_SC03_001.c b/src/ov_SC03_001/ov_SC03_001.c index 2ec20e0206..174c88c067 100644 --- a/src/ov_SC03_001/ov_SC03_001.c +++ b/src/ov_SC03_001/ov_SC03_001.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_001/ov_SC03_001_after.c b/src/ov_SC03_001/ov_SC03_001_after.c index ac76af04aa..b300a7339c 100644 --- a/src/ov_SC03_001/ov_SC03_001_after.c +++ b/src/ov_SC03_001/ov_SC03_001_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_001/ov_SC03_001_jr_8012ACE0.c b/src/ov_SC03_001/ov_SC03_001_jr_8012ACE0.c index a9254d4fd4..b7c7bd195e 100644 --- a/src/ov_SC03_001/ov_SC03_001_jr_8012ACE0.c +++ b/src/ov_SC03_001/ov_SC03_001_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1103,23 +1061,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1152,29 +1094,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1936,25 +1856,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2057,15 +1959,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2097,37 +1991,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2551,35 +2415,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_001/ov_SC03_001_jr_80135D20.c b/src/ov_SC03_001/ov_SC03_001_jr_80135D20.c index 93939a77f1..61dc76001c 100644 --- a/src/ov_SC03_001/ov_SC03_001_jr_80135D20.c +++ b/src/ov_SC03_001/ov_SC03_001_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_001/ov_SC03_001_jr_801380E0.c b/src/ov_SC03_001/ov_SC03_001_jr_801380E0.c index 8e661f11db..123c444690 100644 --- a/src/ov_SC03_001/ov_SC03_001_jr_801380E0.c +++ b/src/ov_SC03_001/ov_SC03_001_jr_801380E0.c @@ -1092,43 +1092,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 cf3b2a2944..568dab4ee1 100644 --- a/src/ov_SC03_001/ov_SC03_001_jr_8015AE2C.c +++ b/src/ov_SC03_001/ov_SC03_001_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_001/ov_SC03_001_jr_8015C32C.c b/src/ov_SC03_001/ov_SC03_001_jr_8015C32C.c index 2cc772d5f5..bd5fc4a4e1 100644 --- a/src/ov_SC03_001/ov_SC03_001_jr_8015C32C.c +++ b/src/ov_SC03_001/ov_SC03_001_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_001/ov_SC03_001_jr_8016AB6C.c b/src/ov_SC03_001/ov_SC03_001_jr_8016AB6C.c index f968dff8ac..45b587cc65 100644 --- a/src/ov_SC03_001/ov_SC03_001_jr_8016AB6C.c +++ b/src/ov_SC03_001/ov_SC03_001_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_001/ov_SC03_001_jr_80171B4C.c b/src/ov_SC03_001/ov_SC03_001_jr_80171B4C.c index d85114a317..41f71cc20c 100644 --- a/src/ov_SC03_001/ov_SC03_001_jr_80171B4C.c +++ b/src/ov_SC03_001/ov_SC03_001_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_001/ov_SC03_001_jr_801734BC.c b/src/ov_SC03_001/ov_SC03_001_jr_801734BC.c index a6398e9feb..b7c1a9e785 100644 --- a/src/ov_SC03_001/ov_SC03_001_jr_801734BC.c +++ b/src/ov_SC03_001/ov_SC03_001_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_001/ov_SC03_001_o0c.c b/src/ov_SC03_001/ov_SC03_001_o0c.c index d0e52133f8..2a0bd5480d 100644 --- a/src/ov_SC03_001/ov_SC03_001_o0c.c +++ b/src/ov_SC03_001/ov_SC03_001_o0c.c @@ -1017,24 +1017,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_002/ov_SC03_002.c b/src/ov_SC03_002/ov_SC03_002.c index 17c7128d14..4e80e0f5f7 100644 --- a/src/ov_SC03_002/ov_SC03_002.c +++ b/src/ov_SC03_002/ov_SC03_002.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_002/ov_SC03_002_after.c b/src/ov_SC03_002/ov_SC03_002_after.c index ceba36da6e..0188814ad5 100644 --- a/src/ov_SC03_002/ov_SC03_002_after.c +++ b/src/ov_SC03_002/ov_SC03_002_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_002/ov_SC03_002_jr_8012ACE0.c b/src/ov_SC03_002/ov_SC03_002_jr_8012ACE0.c index 5a2d324cd4..548c03b2fc 100644 --- a/src/ov_SC03_002/ov_SC03_002_jr_8012ACE0.c +++ b/src/ov_SC03_002/ov_SC03_002_jr_8012ACE0.c @@ -330,49 +330,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1107,23 +1065,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1156,29 +1098,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1940,25 +1860,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2061,15 +1963,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2101,37 +1995,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2555,35 +2419,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_002/ov_SC03_002_jr_80135D20.c b/src/ov_SC03_002/ov_SC03_002_jr_80135D20.c index 4fb7e1a360..8d810a0198 100644 --- a/src/ov_SC03_002/ov_SC03_002_jr_80135D20.c +++ b/src/ov_SC03_002/ov_SC03_002_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_002/ov_SC03_002_jr_801380E0.c b/src/ov_SC03_002/ov_SC03_002_jr_801380E0.c index d5b012d23a..e16f06f6cc 100644 --- a/src/ov_SC03_002/ov_SC03_002_jr_801380E0.c +++ b/src/ov_SC03_002/ov_SC03_002_jr_801380E0.c @@ -1092,43 +1092,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 f4376526b3..1bf45217f6 100644 --- a/src/ov_SC03_002/ov_SC03_002_jr_8015AE2C.c +++ b/src/ov_SC03_002/ov_SC03_002_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_002/ov_SC03_002_jr_8015C32C.c b/src/ov_SC03_002/ov_SC03_002_jr_8015C32C.c index 2985d6e687..89cce88258 100644 --- a/src/ov_SC03_002/ov_SC03_002_jr_8015C32C.c +++ b/src/ov_SC03_002/ov_SC03_002_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_002/ov_SC03_002_jr_8016AB6C.c b/src/ov_SC03_002/ov_SC03_002_jr_8016AB6C.c index 190bb8adf7..4ce810b69f 100644 --- a/src/ov_SC03_002/ov_SC03_002_jr_8016AB6C.c +++ b/src/ov_SC03_002/ov_SC03_002_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_002/ov_SC03_002_jr_80171B4C.c b/src/ov_SC03_002/ov_SC03_002_jr_80171B4C.c index 19dfab218f..883d9a09e2 100644 --- a/src/ov_SC03_002/ov_SC03_002_jr_80171B4C.c +++ b/src/ov_SC03_002/ov_SC03_002_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_002/ov_SC03_002_jr_801734BC.c b/src/ov_SC03_002/ov_SC03_002_jr_801734BC.c index a8a4a5066b..4590598573 100644 --- a/src/ov_SC03_002/ov_SC03_002_jr_801734BC.c +++ b/src/ov_SC03_002/ov_SC03_002_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_002/ov_SC03_002_o0c.c b/src/ov_SC03_002/ov_SC03_002_o0c.c index 17425603dc..3817f67228 100644 --- a/src/ov_SC03_002/ov_SC03_002_o0c.c +++ b/src/ov_SC03_002/ov_SC03_002_o0c.c @@ -1017,24 +1017,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_003/ov_SC03_003.c b/src/ov_SC03_003/ov_SC03_003.c index 26ca9d0735..a5b94f1d39 100644 --- a/src/ov_SC03_003/ov_SC03_003.c +++ b/src/ov_SC03_003/ov_SC03_003.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_003/ov_SC03_003_after.c b/src/ov_SC03_003/ov_SC03_003_after.c index f8a3bf41c8..93d33fec48 100644 --- a/src/ov_SC03_003/ov_SC03_003_after.c +++ b/src/ov_SC03_003/ov_SC03_003_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_003/ov_SC03_003_jr_8012ACE0.c b/src/ov_SC03_003/ov_SC03_003_jr_8012ACE0.c index c1cdbfb41c..6578b448c4 100644 --- a/src/ov_SC03_003/ov_SC03_003_jr_8012ACE0.c +++ b/src/ov_SC03_003/ov_SC03_003_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_003/ov_SC03_003_jr_80135D20.c b/src/ov_SC03_003/ov_SC03_003_jr_80135D20.c index d0a11a841a..9e05fcad5c 100644 --- a/src/ov_SC03_003/ov_SC03_003_jr_80135D20.c +++ b/src/ov_SC03_003/ov_SC03_003_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_003/ov_SC03_003_jr_801380E0.c b/src/ov_SC03_003/ov_SC03_003_jr_801380E0.c index 8b54ed6539..6ad74e4931 100644 --- a/src/ov_SC03_003/ov_SC03_003_jr_801380E0.c +++ b/src/ov_SC03_003/ov_SC03_003_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 5569621859..a7096aac03 100644 --- a/src/ov_SC03_003/ov_SC03_003_jr_8015AE2C.c +++ b/src/ov_SC03_003/ov_SC03_003_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_003/ov_SC03_003_jr_8015C32C.c b/src/ov_SC03_003/ov_SC03_003_jr_8015C32C.c index d1f97dbea5..127ea8b3ee 100644 --- a/src/ov_SC03_003/ov_SC03_003_jr_8015C32C.c +++ b/src/ov_SC03_003/ov_SC03_003_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_003/ov_SC03_003_jr_8016AB6C.c b/src/ov_SC03_003/ov_SC03_003_jr_8016AB6C.c index 08453c41e5..64efcd0445 100644 --- a/src/ov_SC03_003/ov_SC03_003_jr_8016AB6C.c +++ b/src/ov_SC03_003/ov_SC03_003_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_003/ov_SC03_003_jr_80171B4C.c b/src/ov_SC03_003/ov_SC03_003_jr_80171B4C.c index cad3c50b53..ab1216b2dc 100644 --- a/src/ov_SC03_003/ov_SC03_003_jr_80171B4C.c +++ b/src/ov_SC03_003/ov_SC03_003_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_003/ov_SC03_003_jr_801734BC.c b/src/ov_SC03_003/ov_SC03_003_jr_801734BC.c index 5890179278..726e3a2f8b 100644 --- a/src/ov_SC03_003/ov_SC03_003_jr_801734BC.c +++ b/src/ov_SC03_003/ov_SC03_003_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_003/ov_SC03_003_o0c.c b/src/ov_SC03_003/ov_SC03_003_o0c.c index ecf40f41d0..85483f6e82 100644 --- a/src/ov_SC03_003/ov_SC03_003_o0c.c +++ b/src/ov_SC03_003/ov_SC03_003_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_006/ov_SC03_006.c b/src/ov_SC03_006/ov_SC03_006.c index 95ab3a35a7..9a0d924e74 100644 --- a/src/ov_SC03_006/ov_SC03_006.c +++ b/src/ov_SC03_006/ov_SC03_006.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_006/ov_SC03_006_after.c b/src/ov_SC03_006/ov_SC03_006_after.c index 4a2d7f4de9..d6ff802ade 100644 --- a/src/ov_SC03_006/ov_SC03_006_after.c +++ b/src/ov_SC03_006/ov_SC03_006_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_006/ov_SC03_006_jr_8012ACE0.c b/src/ov_SC03_006/ov_SC03_006_jr_8012ACE0.c index f5812fa6a1..612b1e803b 100644 --- a/src/ov_SC03_006/ov_SC03_006_jr_8012ACE0.c +++ b/src/ov_SC03_006/ov_SC03_006_jr_8012ACE0.c @@ -330,49 +330,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1107,23 +1065,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1156,29 +1098,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1940,25 +1860,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2061,15 +1963,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2101,37 +1995,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2555,35 +2419,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_006/ov_SC03_006_jr_80135D20.c b/src/ov_SC03_006/ov_SC03_006_jr_80135D20.c index 6920977b15..3c87286f47 100644 --- a/src/ov_SC03_006/ov_SC03_006_jr_80135D20.c +++ b/src/ov_SC03_006/ov_SC03_006_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_006/ov_SC03_006_jr_801380E0.c b/src/ov_SC03_006/ov_SC03_006_jr_801380E0.c index 9b220a8c7c..7c5c2c1ca8 100644 --- a/src/ov_SC03_006/ov_SC03_006_jr_801380E0.c +++ b/src/ov_SC03_006/ov_SC03_006_jr_801380E0.c @@ -1092,43 +1092,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 6398f4f94a..54de550419 100644 --- a/src/ov_SC03_006/ov_SC03_006_jr_8015AE2C.c +++ b/src/ov_SC03_006/ov_SC03_006_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_006/ov_SC03_006_jr_8015C32C.c b/src/ov_SC03_006/ov_SC03_006_jr_8015C32C.c index 941f26c0fa..f3fbafbe5c 100644 --- a/src/ov_SC03_006/ov_SC03_006_jr_8015C32C.c +++ b/src/ov_SC03_006/ov_SC03_006_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_006/ov_SC03_006_jr_8016AB6C.c b/src/ov_SC03_006/ov_SC03_006_jr_8016AB6C.c index d8f3248b23..2680e26d8f 100644 --- a/src/ov_SC03_006/ov_SC03_006_jr_8016AB6C.c +++ b/src/ov_SC03_006/ov_SC03_006_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_006/ov_SC03_006_jr_80171B4C.c b/src/ov_SC03_006/ov_SC03_006_jr_80171B4C.c index 1cee908417..371f77b5e3 100644 --- a/src/ov_SC03_006/ov_SC03_006_jr_80171B4C.c +++ b/src/ov_SC03_006/ov_SC03_006_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_006/ov_SC03_006_jr_801734BC.c b/src/ov_SC03_006/ov_SC03_006_jr_801734BC.c index edd61abd93..04c28ae1cf 100644 --- a/src/ov_SC03_006/ov_SC03_006_jr_801734BC.c +++ b/src/ov_SC03_006/ov_SC03_006_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_006/ov_SC03_006_o0c.c b/src/ov_SC03_006/ov_SC03_006_o0c.c index ba71802e92..712ace3886 100644 --- a/src/ov_SC03_006/ov_SC03_006_o0c.c +++ b/src/ov_SC03_006/ov_SC03_006_o0c.c @@ -1017,24 +1017,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_007/ov_SC03_007.c b/src/ov_SC03_007/ov_SC03_007.c index 2e46f05a4d..b2f5595f0e 100644 --- a/src/ov_SC03_007/ov_SC03_007.c +++ b/src/ov_SC03_007/ov_SC03_007.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_007/ov_SC03_007_after.c b/src/ov_SC03_007/ov_SC03_007_after.c index fc7af2845c..bdb3b4acfc 100644 --- a/src/ov_SC03_007/ov_SC03_007_after.c +++ b/src/ov_SC03_007/ov_SC03_007_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_007/ov_SC03_007_jr_8012ACE0.c b/src/ov_SC03_007/ov_SC03_007_jr_8012ACE0.c index bc6ac40533..7894488edb 100644 --- a/src/ov_SC03_007/ov_SC03_007_jr_8012ACE0.c +++ b/src/ov_SC03_007/ov_SC03_007_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_007/ov_SC03_007_jr_80135D20.c b/src/ov_SC03_007/ov_SC03_007_jr_80135D20.c index 4817f92563..a80dfa3e7a 100644 --- a/src/ov_SC03_007/ov_SC03_007_jr_80135D20.c +++ b/src/ov_SC03_007/ov_SC03_007_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_007/ov_SC03_007_jr_801380E0.c b/src/ov_SC03_007/ov_SC03_007_jr_801380E0.c index 3cf82a865a..6919dd91ec 100644 --- a/src/ov_SC03_007/ov_SC03_007_jr_801380E0.c +++ b/src/ov_SC03_007/ov_SC03_007_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 382be0c964..079c3279f5 100644 --- a/src/ov_SC03_007/ov_SC03_007_jr_8015AE2C.c +++ b/src/ov_SC03_007/ov_SC03_007_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_007/ov_SC03_007_jr_8015C32C.c b/src/ov_SC03_007/ov_SC03_007_jr_8015C32C.c index a71d59eacc..1a61b5c9d9 100644 --- a/src/ov_SC03_007/ov_SC03_007_jr_8015C32C.c +++ b/src/ov_SC03_007/ov_SC03_007_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_007/ov_SC03_007_jr_8016AB6C.c b/src/ov_SC03_007/ov_SC03_007_jr_8016AB6C.c index 5bd4546639..0b9290216c 100644 --- a/src/ov_SC03_007/ov_SC03_007_jr_8016AB6C.c +++ b/src/ov_SC03_007/ov_SC03_007_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_007/ov_SC03_007_jr_80171B4C.c b/src/ov_SC03_007/ov_SC03_007_jr_80171B4C.c index 9629f6cbb6..ee09d2a25a 100644 --- a/src/ov_SC03_007/ov_SC03_007_jr_80171B4C.c +++ b/src/ov_SC03_007/ov_SC03_007_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_007/ov_SC03_007_jr_801734BC.c b/src/ov_SC03_007/ov_SC03_007_jr_801734BC.c index b1e9288a8a..e384c930bd 100644 --- a/src/ov_SC03_007/ov_SC03_007_jr_801734BC.c +++ b/src/ov_SC03_007/ov_SC03_007_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_007/ov_SC03_007_o0c.c b/src/ov_SC03_007/ov_SC03_007_o0c.c index 94df4e80b3..03257f8742 100644 --- a/src/ov_SC03_007/ov_SC03_007_o0c.c +++ b/src/ov_SC03_007/ov_SC03_007_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_010/ov_SC03_010.c b/src/ov_SC03_010/ov_SC03_010.c index ee781a1e47..f6dc33a40e 100644 --- a/src/ov_SC03_010/ov_SC03_010.c +++ b/src/ov_SC03_010/ov_SC03_010.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_010/ov_SC03_010_after.c b/src/ov_SC03_010/ov_SC03_010_after.c index 3710b2a256..b842d2b9a6 100644 --- a/src/ov_SC03_010/ov_SC03_010_after.c +++ b/src/ov_SC03_010/ov_SC03_010_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_010/ov_SC03_010_jr_8012ACE0.c b/src/ov_SC03_010/ov_SC03_010_jr_8012ACE0.c index 2813aa801f..393b513e15 100644 --- a/src/ov_SC03_010/ov_SC03_010_jr_8012ACE0.c +++ b/src/ov_SC03_010/ov_SC03_010_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_010/ov_SC03_010_jr_80135D20.c b/src/ov_SC03_010/ov_SC03_010_jr_80135D20.c index 35156537f8..481f5ce5f0 100644 --- a/src/ov_SC03_010/ov_SC03_010_jr_80135D20.c +++ b/src/ov_SC03_010/ov_SC03_010_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_010/ov_SC03_010_jr_801380E0.c b/src/ov_SC03_010/ov_SC03_010_jr_801380E0.c index 7f8ab6414e..5a4ade1d8b 100644 --- a/src/ov_SC03_010/ov_SC03_010_jr_801380E0.c +++ b/src/ov_SC03_010/ov_SC03_010_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 2ae580ef72..dbb735969b 100644 --- a/src/ov_SC03_010/ov_SC03_010_jr_8015AE2C.c +++ b/src/ov_SC03_010/ov_SC03_010_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_010/ov_SC03_010_jr_8015C32C.c b/src/ov_SC03_010/ov_SC03_010_jr_8015C32C.c index d647c221d3..43aef469e7 100644 --- a/src/ov_SC03_010/ov_SC03_010_jr_8015C32C.c +++ b/src/ov_SC03_010/ov_SC03_010_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_010/ov_SC03_010_jr_8016AB6C.c b/src/ov_SC03_010/ov_SC03_010_jr_8016AB6C.c index 90d3a5e6b0..446299b225 100644 --- a/src/ov_SC03_010/ov_SC03_010_jr_8016AB6C.c +++ b/src/ov_SC03_010/ov_SC03_010_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_010/ov_SC03_010_jr_80171B4C.c b/src/ov_SC03_010/ov_SC03_010_jr_80171B4C.c index 81b4affd45..c8d7d97eb8 100644 --- a/src/ov_SC03_010/ov_SC03_010_jr_80171B4C.c +++ b/src/ov_SC03_010/ov_SC03_010_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_010/ov_SC03_010_jr_801734BC.c b/src/ov_SC03_010/ov_SC03_010_jr_801734BC.c index 0f1b366eed..a98978e659 100644 --- a/src/ov_SC03_010/ov_SC03_010_jr_801734BC.c +++ b/src/ov_SC03_010/ov_SC03_010_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_010/ov_SC03_010_o0c.c b/src/ov_SC03_010/ov_SC03_010_o0c.c index 9da00a2530..006986b1b1 100644 --- a/src/ov_SC03_010/ov_SC03_010_o0c.c +++ b/src/ov_SC03_010/ov_SC03_010_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_011/ov_SC03_011.c b/src/ov_SC03_011/ov_SC03_011.c index 84062b952a..7d9b33ef33 100644 --- a/src/ov_SC03_011/ov_SC03_011.c +++ b/src/ov_SC03_011/ov_SC03_011.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_011/ov_SC03_011_after.c b/src/ov_SC03_011/ov_SC03_011_after.c index 86ad23e71b..578285e918 100644 --- a/src/ov_SC03_011/ov_SC03_011_after.c +++ b/src/ov_SC03_011/ov_SC03_011_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_011/ov_SC03_011_jr_8012ACE0.c b/src/ov_SC03_011/ov_SC03_011_jr_8012ACE0.c index dd4c99ddae..f148fc36a7 100644 --- a/src/ov_SC03_011/ov_SC03_011_jr_8012ACE0.c +++ b/src/ov_SC03_011/ov_SC03_011_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_011/ov_SC03_011_jr_80135D20.c b/src/ov_SC03_011/ov_SC03_011_jr_80135D20.c index fa68a4ce29..941ee0cb13 100644 --- a/src/ov_SC03_011/ov_SC03_011_jr_80135D20.c +++ b/src/ov_SC03_011/ov_SC03_011_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_011/ov_SC03_011_jr_801380E0.c b/src/ov_SC03_011/ov_SC03_011_jr_801380E0.c index a0a6fc9ca1..ba48b4edf0 100644 --- a/src/ov_SC03_011/ov_SC03_011_jr_801380E0.c +++ b/src/ov_SC03_011/ov_SC03_011_jr_801380E0.c @@ -1100,43 +1100,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 5a7b04b809..a2b5566aab 100644 --- a/src/ov_SC03_011/ov_SC03_011_jr_8015AE2C.c +++ b/src/ov_SC03_011/ov_SC03_011_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_011/ov_SC03_011_jr_8015C32C.c b/src/ov_SC03_011/ov_SC03_011_jr_8015C32C.c index 72604add11..d98b56858e 100644 --- a/src/ov_SC03_011/ov_SC03_011_jr_8015C32C.c +++ b/src/ov_SC03_011/ov_SC03_011_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_011/ov_SC03_011_jr_8016AB6C.c b/src/ov_SC03_011/ov_SC03_011_jr_8016AB6C.c index 7c2497284e..bcf120fa19 100644 --- a/src/ov_SC03_011/ov_SC03_011_jr_8016AB6C.c +++ b/src/ov_SC03_011/ov_SC03_011_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_011/ov_SC03_011_jr_80171B4C.c b/src/ov_SC03_011/ov_SC03_011_jr_80171B4C.c index 23ce29249c..bb533de6c1 100644 --- a/src/ov_SC03_011/ov_SC03_011_jr_80171B4C.c +++ b/src/ov_SC03_011/ov_SC03_011_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_011/ov_SC03_011_jr_801734BC.c b/src/ov_SC03_011/ov_SC03_011_jr_801734BC.c index 194aab611b..58bb2de958 100644 --- a/src/ov_SC03_011/ov_SC03_011_jr_801734BC.c +++ b/src/ov_SC03_011/ov_SC03_011_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_011/ov_SC03_011_o0c.c b/src/ov_SC03_011/ov_SC03_011_o0c.c index 40a17aa62c..5097b949cd 100644 --- a/src/ov_SC03_011/ov_SC03_011_o0c.c +++ b/src/ov_SC03_011/ov_SC03_011_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_012/ov_SC03_012.c b/src/ov_SC03_012/ov_SC03_012.c index 5d0131d36b..0e1066d0ac 100644 --- a/src/ov_SC03_012/ov_SC03_012.c +++ b/src/ov_SC03_012/ov_SC03_012.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_012/ov_SC03_012_after.c b/src/ov_SC03_012/ov_SC03_012_after.c index 1ea11fc553..a312d1033f 100644 --- a/src/ov_SC03_012/ov_SC03_012_after.c +++ b/src/ov_SC03_012/ov_SC03_012_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_012/ov_SC03_012_jr_8012ACE0.c b/src/ov_SC03_012/ov_SC03_012_jr_8012ACE0.c index b3e880d6b7..f4b857d0e6 100644 --- a/src/ov_SC03_012/ov_SC03_012_jr_8012ACE0.c +++ b/src/ov_SC03_012/ov_SC03_012_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_012/ov_SC03_012_jr_80135D20.c b/src/ov_SC03_012/ov_SC03_012_jr_80135D20.c index 45c8a9a493..29bd9bccd0 100644 --- a/src/ov_SC03_012/ov_SC03_012_jr_80135D20.c +++ b/src/ov_SC03_012/ov_SC03_012_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_012/ov_SC03_012_jr_801380E0.c b/src/ov_SC03_012/ov_SC03_012_jr_801380E0.c index 412ddf1976..08a8b85c3c 100644 --- a/src/ov_SC03_012/ov_SC03_012_jr_801380E0.c +++ b/src/ov_SC03_012/ov_SC03_012_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 c8a9a34833..0bd3106269 100644 --- a/src/ov_SC03_012/ov_SC03_012_jr_8015AE2C.c +++ b/src/ov_SC03_012/ov_SC03_012_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_012/ov_SC03_012_jr_8015C32C.c b/src/ov_SC03_012/ov_SC03_012_jr_8015C32C.c index e032a9b42f..c092738dd7 100644 --- a/src/ov_SC03_012/ov_SC03_012_jr_8015C32C.c +++ b/src/ov_SC03_012/ov_SC03_012_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_012/ov_SC03_012_jr_8016AB6C.c b/src/ov_SC03_012/ov_SC03_012_jr_8016AB6C.c index b0a90c05d8..38e1045261 100644 --- a/src/ov_SC03_012/ov_SC03_012_jr_8016AB6C.c +++ b/src/ov_SC03_012/ov_SC03_012_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_012/ov_SC03_012_jr_80171B4C.c b/src/ov_SC03_012/ov_SC03_012_jr_80171B4C.c index 8940d663fe..aced6fec9c 100644 --- a/src/ov_SC03_012/ov_SC03_012_jr_80171B4C.c +++ b/src/ov_SC03_012/ov_SC03_012_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_012/ov_SC03_012_jr_801734BC.c b/src/ov_SC03_012/ov_SC03_012_jr_801734BC.c index f7ba2848ff..c60107e08f 100644 --- a/src/ov_SC03_012/ov_SC03_012_jr_801734BC.c +++ b/src/ov_SC03_012/ov_SC03_012_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_012/ov_SC03_012_o0c.c b/src/ov_SC03_012/ov_SC03_012_o0c.c index 5455628f68..851fd8bd72 100644 --- a/src/ov_SC03_012/ov_SC03_012_o0c.c +++ b/src/ov_SC03_012/ov_SC03_012_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_013/ov_SC03_013.c b/src/ov_SC03_013/ov_SC03_013.c index bd11bf20be..6c321ecef6 100644 --- a/src/ov_SC03_013/ov_SC03_013.c +++ b/src/ov_SC03_013/ov_SC03_013.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_013/ov_SC03_013_after.c b/src/ov_SC03_013/ov_SC03_013_after.c index fd982b0f2a..e1f591eb99 100644 --- a/src/ov_SC03_013/ov_SC03_013_after.c +++ b/src/ov_SC03_013/ov_SC03_013_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_013/ov_SC03_013_jr_8012ACE0.c b/src/ov_SC03_013/ov_SC03_013_jr_8012ACE0.c index 81279d36a5..25b148583a 100644 --- a/src/ov_SC03_013/ov_SC03_013_jr_8012ACE0.c +++ b/src/ov_SC03_013/ov_SC03_013_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_013/ov_SC03_013_jr_80135D20.c b/src/ov_SC03_013/ov_SC03_013_jr_80135D20.c index 09c5a39a5e..250ab817a4 100644 --- a/src/ov_SC03_013/ov_SC03_013_jr_80135D20.c +++ b/src/ov_SC03_013/ov_SC03_013_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_013/ov_SC03_013_jr_801380E0.c b/src/ov_SC03_013/ov_SC03_013_jr_801380E0.c index e9dbc82275..aaedea41d3 100644 --- a/src/ov_SC03_013/ov_SC03_013_jr_801380E0.c +++ b/src/ov_SC03_013/ov_SC03_013_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 1734396d8e..81d394d60c 100644 --- a/src/ov_SC03_013/ov_SC03_013_jr_8015AE2C.c +++ b/src/ov_SC03_013/ov_SC03_013_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_013/ov_SC03_013_jr_8015C32C.c b/src/ov_SC03_013/ov_SC03_013_jr_8015C32C.c index 758e11bb0a..93b9213c4b 100644 --- a/src/ov_SC03_013/ov_SC03_013_jr_8015C32C.c +++ b/src/ov_SC03_013/ov_SC03_013_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_013/ov_SC03_013_jr_8016AB6C.c b/src/ov_SC03_013/ov_SC03_013_jr_8016AB6C.c index 8d524e47db..18dbe580c7 100644 --- a/src/ov_SC03_013/ov_SC03_013_jr_8016AB6C.c +++ b/src/ov_SC03_013/ov_SC03_013_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_013/ov_SC03_013_jr_80171B4C.c b/src/ov_SC03_013/ov_SC03_013_jr_80171B4C.c index 15cc0cce6d..89a8109220 100644 --- a/src/ov_SC03_013/ov_SC03_013_jr_80171B4C.c +++ b/src/ov_SC03_013/ov_SC03_013_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_013/ov_SC03_013_jr_801734BC.c b/src/ov_SC03_013/ov_SC03_013_jr_801734BC.c index 2ce4c82362..0001445f23 100644 --- a/src/ov_SC03_013/ov_SC03_013_jr_801734BC.c +++ b/src/ov_SC03_013/ov_SC03_013_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_013/ov_SC03_013_o0c.c b/src/ov_SC03_013/ov_SC03_013_o0c.c index 4c35337007..8cad210455 100644 --- a/src/ov_SC03_013/ov_SC03_013_o0c.c +++ b/src/ov_SC03_013/ov_SC03_013_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_014/ov_SC03_014.c b/src/ov_SC03_014/ov_SC03_014.c index 1242b7d59e..68b68cf10b 100644 --- a/src/ov_SC03_014/ov_SC03_014.c +++ b/src/ov_SC03_014/ov_SC03_014.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_014/ov_SC03_014_after.c b/src/ov_SC03_014/ov_SC03_014_after.c index 00686d9973..8f5fd582b4 100644 --- a/src/ov_SC03_014/ov_SC03_014_after.c +++ b/src/ov_SC03_014/ov_SC03_014_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_014/ov_SC03_014_jr_8012ACE0.c b/src/ov_SC03_014/ov_SC03_014_jr_8012ACE0.c index 1274e83e24..3f6f6514e4 100644 --- a/src/ov_SC03_014/ov_SC03_014_jr_8012ACE0.c +++ b/src/ov_SC03_014/ov_SC03_014_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_014/ov_SC03_014_jr_80135D20.c b/src/ov_SC03_014/ov_SC03_014_jr_80135D20.c index bf2301139b..f55fd344fd 100644 --- a/src/ov_SC03_014/ov_SC03_014_jr_80135D20.c +++ b/src/ov_SC03_014/ov_SC03_014_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_014/ov_SC03_014_jr_801380E0.c b/src/ov_SC03_014/ov_SC03_014_jr_801380E0.c index 4ad0375365..d9e9b42b21 100644 --- a/src/ov_SC03_014/ov_SC03_014_jr_801380E0.c +++ b/src/ov_SC03_014/ov_SC03_014_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 38bd75137f..7cad20281a 100644 --- a/src/ov_SC03_014/ov_SC03_014_jr_8015AE2C.c +++ b/src/ov_SC03_014/ov_SC03_014_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_014/ov_SC03_014_jr_8015C32C.c b/src/ov_SC03_014/ov_SC03_014_jr_8015C32C.c index 7ba20ad448..1e4db307dd 100644 --- a/src/ov_SC03_014/ov_SC03_014_jr_8015C32C.c +++ b/src/ov_SC03_014/ov_SC03_014_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_014/ov_SC03_014_jr_8016AB6C.c b/src/ov_SC03_014/ov_SC03_014_jr_8016AB6C.c index 05d6c3c550..6171416578 100644 --- a/src/ov_SC03_014/ov_SC03_014_jr_8016AB6C.c +++ b/src/ov_SC03_014/ov_SC03_014_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_014/ov_SC03_014_jr_80171B4C.c b/src/ov_SC03_014/ov_SC03_014_jr_80171B4C.c index 8359765df2..fd61bce8b9 100644 --- a/src/ov_SC03_014/ov_SC03_014_jr_80171B4C.c +++ b/src/ov_SC03_014/ov_SC03_014_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_014/ov_SC03_014_jr_801734BC.c b/src/ov_SC03_014/ov_SC03_014_jr_801734BC.c index 602932a877..3d9dd984bf 100644 --- a/src/ov_SC03_014/ov_SC03_014_jr_801734BC.c +++ b/src/ov_SC03_014/ov_SC03_014_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_014/ov_SC03_014_o0e.c b/src/ov_SC03_014/ov_SC03_014_o0e.c index b5304c6277..29c1ed2ef6 100644 --- a/src/ov_SC03_014/ov_SC03_014_o0e.c +++ b/src/ov_SC03_014/ov_SC03_014_o0e.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_015/ov_SC03_015.c b/src/ov_SC03_015/ov_SC03_015.c index 1242b7d59e..68b68cf10b 100644 --- a/src/ov_SC03_015/ov_SC03_015.c +++ b/src/ov_SC03_015/ov_SC03_015.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_015/ov_SC03_015_after.c b/src/ov_SC03_015/ov_SC03_015_after.c index 9942a09b67..d1feb7c5d6 100644 --- a/src/ov_SC03_015/ov_SC03_015_after.c +++ b/src/ov_SC03_015/ov_SC03_015_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_015/ov_SC03_015_jr_8012ACE0.c b/src/ov_SC03_015/ov_SC03_015_jr_8012ACE0.c index 1274e83e24..3f6f6514e4 100644 --- a/src/ov_SC03_015/ov_SC03_015_jr_8012ACE0.c +++ b/src/ov_SC03_015/ov_SC03_015_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_015/ov_SC03_015_jr_80135D20.c b/src/ov_SC03_015/ov_SC03_015_jr_80135D20.c index bf2301139b..f55fd344fd 100644 --- a/src/ov_SC03_015/ov_SC03_015_jr_80135D20.c +++ b/src/ov_SC03_015/ov_SC03_015_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_015/ov_SC03_015_jr_801380E0.c b/src/ov_SC03_015/ov_SC03_015_jr_801380E0.c index 4ad0375365..d9e9b42b21 100644 --- a/src/ov_SC03_015/ov_SC03_015_jr_801380E0.c +++ b/src/ov_SC03_015/ov_SC03_015_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 38bd75137f..7cad20281a 100644 --- a/src/ov_SC03_015/ov_SC03_015_jr_8015AE2C.c +++ b/src/ov_SC03_015/ov_SC03_015_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_015/ov_SC03_015_jr_8015C32C.c b/src/ov_SC03_015/ov_SC03_015_jr_8015C32C.c index 7ba20ad448..1e4db307dd 100644 --- a/src/ov_SC03_015/ov_SC03_015_jr_8015C32C.c +++ b/src/ov_SC03_015/ov_SC03_015_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_015/ov_SC03_015_jr_8016AB6C.c b/src/ov_SC03_015/ov_SC03_015_jr_8016AB6C.c index 05d6c3c550..6171416578 100644 --- a/src/ov_SC03_015/ov_SC03_015_jr_8016AB6C.c +++ b/src/ov_SC03_015/ov_SC03_015_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_015/ov_SC03_015_jr_80171B4C.c b/src/ov_SC03_015/ov_SC03_015_jr_80171B4C.c index 8359765df2..fd61bce8b9 100644 --- a/src/ov_SC03_015/ov_SC03_015_jr_80171B4C.c +++ b/src/ov_SC03_015/ov_SC03_015_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_015/ov_SC03_015_jr_801734BC.c b/src/ov_SC03_015/ov_SC03_015_jr_801734BC.c index 602932a877..3d9dd984bf 100644 --- a/src/ov_SC03_015/ov_SC03_015_jr_801734BC.c +++ b/src/ov_SC03_015/ov_SC03_015_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_015/ov_SC03_015_o0e.c b/src/ov_SC03_015/ov_SC03_015_o0e.c index b5304c6277..29c1ed2ef6 100644 --- a/src/ov_SC03_015/ov_SC03_015_o0e.c +++ b/src/ov_SC03_015/ov_SC03_015_o0e.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_023/ov_SC03_023.c b/src/ov_SC03_023/ov_SC03_023.c index d99d3fbd2b..22d29cf188 100644 --- a/src/ov_SC03_023/ov_SC03_023.c +++ b/src/ov_SC03_023/ov_SC03_023.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_023/ov_SC03_023_after.c b/src/ov_SC03_023/ov_SC03_023_after.c index 9067fbe9ae..0cc27bb184 100644 --- a/src/ov_SC03_023/ov_SC03_023_after.c +++ b/src/ov_SC03_023/ov_SC03_023_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_023/ov_SC03_023_jr_8012ACE0.c b/src/ov_SC03_023/ov_SC03_023_jr_8012ACE0.c index a32c8cd551..3c344d9e9b 100644 --- a/src/ov_SC03_023/ov_SC03_023_jr_8012ACE0.c +++ b/src/ov_SC03_023/ov_SC03_023_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_023/ov_SC03_023_jr_80135D20.c b/src/ov_SC03_023/ov_SC03_023_jr_80135D20.c index d8354cde08..80da3a9787 100644 --- a/src/ov_SC03_023/ov_SC03_023_jr_80135D20.c +++ b/src/ov_SC03_023/ov_SC03_023_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_023/ov_SC03_023_jr_801380E0.c b/src/ov_SC03_023/ov_SC03_023_jr_801380E0.c index 97059df685..ab176b5d54 100644 --- a/src/ov_SC03_023/ov_SC03_023_jr_801380E0.c +++ b/src/ov_SC03_023/ov_SC03_023_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 4db8e5ddf2..ac25224b10 100644 --- a/src/ov_SC03_023/ov_SC03_023_jr_8015AE2C.c +++ b/src/ov_SC03_023/ov_SC03_023_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_023/ov_SC03_023_jr_8015C32C.c b/src/ov_SC03_023/ov_SC03_023_jr_8015C32C.c index 1b15faa229..2e67288c78 100644 --- a/src/ov_SC03_023/ov_SC03_023_jr_8015C32C.c +++ b/src/ov_SC03_023/ov_SC03_023_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_023/ov_SC03_023_jr_8016AB6C.c b/src/ov_SC03_023/ov_SC03_023_jr_8016AB6C.c index fa81ba48b5..e4d94b4e3f 100644 --- a/src/ov_SC03_023/ov_SC03_023_jr_8016AB6C.c +++ b/src/ov_SC03_023/ov_SC03_023_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_023/ov_SC03_023_jr_80171B4C.c b/src/ov_SC03_023/ov_SC03_023_jr_80171B4C.c index 5c14c34d77..4b4d634e34 100644 --- a/src/ov_SC03_023/ov_SC03_023_jr_80171B4C.c +++ b/src/ov_SC03_023/ov_SC03_023_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_023/ov_SC03_023_jr_801734BC.c b/src/ov_SC03_023/ov_SC03_023_jr_801734BC.c index 85c42445e9..4110b42bb6 100644 --- a/src/ov_SC03_023/ov_SC03_023_jr_801734BC.c +++ b/src/ov_SC03_023/ov_SC03_023_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_023/ov_SC03_023_o0c.c b/src/ov_SC03_023/ov_SC03_023_o0c.c index b861a39c68..30ad3534b1 100644 --- a/src/ov_SC03_023/ov_SC03_023_o0c.c +++ b/src/ov_SC03_023/ov_SC03_023_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_024/ov_SC03_024.c b/src/ov_SC03_024/ov_SC03_024.c index a82d512b0a..2034ff17d7 100644 --- a/src/ov_SC03_024/ov_SC03_024.c +++ b/src/ov_SC03_024/ov_SC03_024.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_024/ov_SC03_024_after.c b/src/ov_SC03_024/ov_SC03_024_after.c index b007d83503..b3699b3268 100644 --- a/src/ov_SC03_024/ov_SC03_024_after.c +++ b/src/ov_SC03_024/ov_SC03_024_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_024/ov_SC03_024_jr_8012ACE0.c b/src/ov_SC03_024/ov_SC03_024_jr_8012ACE0.c index cc1c4dff70..663212163c 100644 --- a/src/ov_SC03_024/ov_SC03_024_jr_8012ACE0.c +++ b/src/ov_SC03_024/ov_SC03_024_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_024/ov_SC03_024_jr_80135D20.c b/src/ov_SC03_024/ov_SC03_024_jr_80135D20.c index 35cbb066ea..82a9291539 100644 --- a/src/ov_SC03_024/ov_SC03_024_jr_80135D20.c +++ b/src/ov_SC03_024/ov_SC03_024_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_024/ov_SC03_024_jr_801380E0.c b/src/ov_SC03_024/ov_SC03_024_jr_801380E0.c index 7ff29ff406..a9979bfee7 100644 --- a/src/ov_SC03_024/ov_SC03_024_jr_801380E0.c +++ b/src/ov_SC03_024/ov_SC03_024_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 176b4e666f..822d412207 100644 --- a/src/ov_SC03_024/ov_SC03_024_jr_8015AE2C.c +++ b/src/ov_SC03_024/ov_SC03_024_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_024/ov_SC03_024_jr_8015C32C.c b/src/ov_SC03_024/ov_SC03_024_jr_8015C32C.c index 2237e1a72b..125a62050d 100644 --- a/src/ov_SC03_024/ov_SC03_024_jr_8015C32C.c +++ b/src/ov_SC03_024/ov_SC03_024_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_024/ov_SC03_024_jr_8016AB6C.c b/src/ov_SC03_024/ov_SC03_024_jr_8016AB6C.c index 6ba653a70a..3963bee160 100644 --- a/src/ov_SC03_024/ov_SC03_024_jr_8016AB6C.c +++ b/src/ov_SC03_024/ov_SC03_024_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_024/ov_SC03_024_jr_80171B4C.c b/src/ov_SC03_024/ov_SC03_024_jr_80171B4C.c index 9c33c69145..13db0da7d4 100644 --- a/src/ov_SC03_024/ov_SC03_024_jr_80171B4C.c +++ b/src/ov_SC03_024/ov_SC03_024_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_024/ov_SC03_024_jr_801734BC.c b/src/ov_SC03_024/ov_SC03_024_jr_801734BC.c index fa93c259b5..3957cea1f2 100644 --- a/src/ov_SC03_024/ov_SC03_024_jr_801734BC.c +++ b/src/ov_SC03_024/ov_SC03_024_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_024/ov_SC03_024_o0c.c b/src/ov_SC03_024/ov_SC03_024_o0c.c index b60a4f0498..b7c1612f07 100644 --- a/src/ov_SC03_024/ov_SC03_024_o0c.c +++ b/src/ov_SC03_024/ov_SC03_024_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_028/ov_SC03_028.c b/src/ov_SC03_028/ov_SC03_028.c index 30dc846697..24b914bf53 100644 --- a/src/ov_SC03_028/ov_SC03_028.c +++ b/src/ov_SC03_028/ov_SC03_028.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_028/ov_SC03_028_after.c b/src/ov_SC03_028/ov_SC03_028_after.c index 0ee04ed8f7..1d8674b5d5 100644 --- a/src/ov_SC03_028/ov_SC03_028_after.c +++ b/src/ov_SC03_028/ov_SC03_028_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_028/ov_SC03_028_jr_8012ACE0.c b/src/ov_SC03_028/ov_SC03_028_jr_8012ACE0.c index 4ee0d29fa3..35d7f693cb 100644 --- a/src/ov_SC03_028/ov_SC03_028_jr_8012ACE0.c +++ b/src/ov_SC03_028/ov_SC03_028_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_028/ov_SC03_028_jr_80135D20.c b/src/ov_SC03_028/ov_SC03_028_jr_80135D20.c index 299e00a09d..c84d679efb 100644 --- a/src/ov_SC03_028/ov_SC03_028_jr_80135D20.c +++ b/src/ov_SC03_028/ov_SC03_028_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_028/ov_SC03_028_jr_801380E0.c b/src/ov_SC03_028/ov_SC03_028_jr_801380E0.c index 2cfd2f5d8e..4d891c8075 100644 --- a/src/ov_SC03_028/ov_SC03_028_jr_801380E0.c +++ b/src/ov_SC03_028/ov_SC03_028_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 64bf476c7e..246e5b21e4 100644 --- a/src/ov_SC03_028/ov_SC03_028_jr_8015AE2C.c +++ b/src/ov_SC03_028/ov_SC03_028_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_028/ov_SC03_028_jr_8015C32C.c b/src/ov_SC03_028/ov_SC03_028_jr_8015C32C.c index 470882adc3..2d28e345e2 100644 --- a/src/ov_SC03_028/ov_SC03_028_jr_8015C32C.c +++ b/src/ov_SC03_028/ov_SC03_028_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_028/ov_SC03_028_jr_8016AB6C.c b/src/ov_SC03_028/ov_SC03_028_jr_8016AB6C.c index 8f256e13d7..1ed62f1cd3 100644 --- a/src/ov_SC03_028/ov_SC03_028_jr_8016AB6C.c +++ b/src/ov_SC03_028/ov_SC03_028_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_028/ov_SC03_028_jr_80171B4C.c b/src/ov_SC03_028/ov_SC03_028_jr_80171B4C.c index cdf3ee3dd0..7ea54c0c68 100644 --- a/src/ov_SC03_028/ov_SC03_028_jr_80171B4C.c +++ b/src/ov_SC03_028/ov_SC03_028_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_028/ov_SC03_028_jr_801734BC.c b/src/ov_SC03_028/ov_SC03_028_jr_801734BC.c index 8d75b2d7e8..5b76480c8e 100644 --- a/src/ov_SC03_028/ov_SC03_028_jr_801734BC.c +++ b/src/ov_SC03_028/ov_SC03_028_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_028/ov_SC03_028_o0c.c b/src/ov_SC03_028/ov_SC03_028_o0c.c index aa30ab69ad..6223bfd7cf 100644 --- a/src/ov_SC03_028/ov_SC03_028_o0c.c +++ b/src/ov_SC03_028/ov_SC03_028_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_029/ov_SC03_029.c b/src/ov_SC03_029/ov_SC03_029.c index 3964a716ad..71509d8d15 100644 --- a/src/ov_SC03_029/ov_SC03_029.c +++ b/src/ov_SC03_029/ov_SC03_029.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_029/ov_SC03_029_after.c b/src/ov_SC03_029/ov_SC03_029_after.c index d4c1df0270..35815d8d82 100644 --- a/src/ov_SC03_029/ov_SC03_029_after.c +++ b/src/ov_SC03_029/ov_SC03_029_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_029/ov_SC03_029_jr_8012ACE0.c b/src/ov_SC03_029/ov_SC03_029_jr_8012ACE0.c index f997d2fb8a..50be97a27d 100644 --- a/src/ov_SC03_029/ov_SC03_029_jr_8012ACE0.c +++ b/src/ov_SC03_029/ov_SC03_029_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_029/ov_SC03_029_jr_80135D20.c b/src/ov_SC03_029/ov_SC03_029_jr_80135D20.c index 86b3743784..e95c8077dc 100644 --- a/src/ov_SC03_029/ov_SC03_029_jr_80135D20.c +++ b/src/ov_SC03_029/ov_SC03_029_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_029/ov_SC03_029_jr_801380E0.c b/src/ov_SC03_029/ov_SC03_029_jr_801380E0.c index 100db45f53..3d9ed291e8 100644 --- a/src/ov_SC03_029/ov_SC03_029_jr_801380E0.c +++ b/src/ov_SC03_029/ov_SC03_029_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 38014b0cfa..acb91f3c01 100644 --- a/src/ov_SC03_029/ov_SC03_029_jr_8015AE2C.c +++ b/src/ov_SC03_029/ov_SC03_029_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_029/ov_SC03_029_jr_8015C32C.c b/src/ov_SC03_029/ov_SC03_029_jr_8015C32C.c index e62bc0a654..f59a99f6f9 100644 --- a/src/ov_SC03_029/ov_SC03_029_jr_8015C32C.c +++ b/src/ov_SC03_029/ov_SC03_029_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_029/ov_SC03_029_jr_8016AB6C.c b/src/ov_SC03_029/ov_SC03_029_jr_8016AB6C.c index 26bf83bc6d..8b9218597b 100644 --- a/src/ov_SC03_029/ov_SC03_029_jr_8016AB6C.c +++ b/src/ov_SC03_029/ov_SC03_029_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_029/ov_SC03_029_jr_80171B4C.c b/src/ov_SC03_029/ov_SC03_029_jr_80171B4C.c index 301b3217a6..0ac87f4702 100644 --- a/src/ov_SC03_029/ov_SC03_029_jr_80171B4C.c +++ b/src/ov_SC03_029/ov_SC03_029_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_029/ov_SC03_029_jr_801734BC.c b/src/ov_SC03_029/ov_SC03_029_jr_801734BC.c index 647a1c5209..bf44ec4a40 100644 --- a/src/ov_SC03_029/ov_SC03_029_jr_801734BC.c +++ b/src/ov_SC03_029/ov_SC03_029_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_029/ov_SC03_029_o0c.c b/src/ov_SC03_029/ov_SC03_029_o0c.c index a56fa98b03..c1cd182381 100644 --- a/src/ov_SC03_029/ov_SC03_029_o0c.c +++ b/src/ov_SC03_029/ov_SC03_029_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_030/ov_SC03_030.c b/src/ov_SC03_030/ov_SC03_030.c index 09051bb6e4..3f149cb6e8 100644 --- a/src/ov_SC03_030/ov_SC03_030.c +++ b/src/ov_SC03_030/ov_SC03_030.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_030/ov_SC03_030_after.c b/src/ov_SC03_030/ov_SC03_030_after.c index ef28d81d4c..eb26276a75 100644 --- a/src/ov_SC03_030/ov_SC03_030_after.c +++ b/src/ov_SC03_030/ov_SC03_030_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_030/ov_SC03_030_jr_8012ACE0.c b/src/ov_SC03_030/ov_SC03_030_jr_8012ACE0.c index bb630f120c..fce006494c 100644 --- a/src/ov_SC03_030/ov_SC03_030_jr_8012ACE0.c +++ b/src/ov_SC03_030/ov_SC03_030_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_030/ov_SC03_030_jr_80135D20.c b/src/ov_SC03_030/ov_SC03_030_jr_80135D20.c index e4582cd5fd..02c85e1a50 100644 --- a/src/ov_SC03_030/ov_SC03_030_jr_80135D20.c +++ b/src/ov_SC03_030/ov_SC03_030_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_030/ov_SC03_030_jr_801380E0.c b/src/ov_SC03_030/ov_SC03_030_jr_801380E0.c index 1eac7ea097..db292e7c31 100644 --- a/src/ov_SC03_030/ov_SC03_030_jr_801380E0.c +++ b/src/ov_SC03_030/ov_SC03_030_jr_801380E0.c @@ -1100,43 +1100,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 134e45d35c..58f4dda726 100644 --- a/src/ov_SC03_030/ov_SC03_030_jr_8015AE2C.c +++ b/src/ov_SC03_030/ov_SC03_030_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_030/ov_SC03_030_jr_8015C32C.c b/src/ov_SC03_030/ov_SC03_030_jr_8015C32C.c index 73fa549c2a..288340903d 100644 --- a/src/ov_SC03_030/ov_SC03_030_jr_8015C32C.c +++ b/src/ov_SC03_030/ov_SC03_030_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_030/ov_SC03_030_jr_8016AB6C.c b/src/ov_SC03_030/ov_SC03_030_jr_8016AB6C.c index 4003c59f07..5596a2cb1c 100644 --- a/src/ov_SC03_030/ov_SC03_030_jr_8016AB6C.c +++ b/src/ov_SC03_030/ov_SC03_030_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_030/ov_SC03_030_jr_80171B4C.c b/src/ov_SC03_030/ov_SC03_030_jr_80171B4C.c index b0cf9b3420..0b28701283 100644 --- a/src/ov_SC03_030/ov_SC03_030_jr_80171B4C.c +++ b/src/ov_SC03_030/ov_SC03_030_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_030/ov_SC03_030_jr_801734BC.c b/src/ov_SC03_030/ov_SC03_030_jr_801734BC.c index 06a04a0cf9..29a5499861 100644 --- a/src/ov_SC03_030/ov_SC03_030_jr_801734BC.c +++ b/src/ov_SC03_030/ov_SC03_030_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_030/ov_SC03_030_o0c.c b/src/ov_SC03_030/ov_SC03_030_o0c.c index 69fc847ad0..0f8fd6fc51 100644 --- a/src/ov_SC03_030/ov_SC03_030_o0c.c +++ b/src/ov_SC03_030/ov_SC03_030_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_031/ov_SC03_031.c b/src/ov_SC03_031/ov_SC03_031.c index ce8c22b4b3..8ad1901a22 100644 --- a/src/ov_SC03_031/ov_SC03_031.c +++ b/src/ov_SC03_031/ov_SC03_031.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_031/ov_SC03_031_after.c b/src/ov_SC03_031/ov_SC03_031_after.c index 6f8e70229b..06f948e54a 100644 --- a/src/ov_SC03_031/ov_SC03_031_after.c +++ b/src/ov_SC03_031/ov_SC03_031_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_031/ov_SC03_031_jr_8012ACE0.c b/src/ov_SC03_031/ov_SC03_031_jr_8012ACE0.c index 34a2c8ce24..96ae371de0 100644 --- a/src/ov_SC03_031/ov_SC03_031_jr_8012ACE0.c +++ b/src/ov_SC03_031/ov_SC03_031_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_031/ov_SC03_031_jr_80135D20.c b/src/ov_SC03_031/ov_SC03_031_jr_80135D20.c index 947227b002..be652a0142 100644 --- a/src/ov_SC03_031/ov_SC03_031_jr_80135D20.c +++ b/src/ov_SC03_031/ov_SC03_031_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_031/ov_SC03_031_jr_801380E0.c b/src/ov_SC03_031/ov_SC03_031_jr_801380E0.c index b7dea1c533..0934a565c0 100644 --- a/src/ov_SC03_031/ov_SC03_031_jr_801380E0.c +++ b/src/ov_SC03_031/ov_SC03_031_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 6ed8f6cad6..fe275469d4 100644 --- a/src/ov_SC03_031/ov_SC03_031_jr_8015AE2C.c +++ b/src/ov_SC03_031/ov_SC03_031_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_031/ov_SC03_031_jr_8015C32C.c b/src/ov_SC03_031/ov_SC03_031_jr_8015C32C.c index f5aa3ce005..cb71d33afc 100644 --- a/src/ov_SC03_031/ov_SC03_031_jr_8015C32C.c +++ b/src/ov_SC03_031/ov_SC03_031_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_031/ov_SC03_031_jr_8016AB6C.c b/src/ov_SC03_031/ov_SC03_031_jr_8016AB6C.c index 6db258165f..400bb2701b 100644 --- a/src/ov_SC03_031/ov_SC03_031_jr_8016AB6C.c +++ b/src/ov_SC03_031/ov_SC03_031_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_031/ov_SC03_031_jr_80171B4C.c b/src/ov_SC03_031/ov_SC03_031_jr_80171B4C.c index 89f0953cb9..e0c3d84a0d 100644 --- a/src/ov_SC03_031/ov_SC03_031_jr_80171B4C.c +++ b/src/ov_SC03_031/ov_SC03_031_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_031/ov_SC03_031_jr_801734BC.c b/src/ov_SC03_031/ov_SC03_031_jr_801734BC.c index bf1bf6ccd4..41419901d0 100644 --- a/src/ov_SC03_031/ov_SC03_031_jr_801734BC.c +++ b/src/ov_SC03_031/ov_SC03_031_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_031/ov_SC03_031_o0c.c b/src/ov_SC03_031/ov_SC03_031_o0c.c index 73c658d8fc..2fdf87d4f9 100644 --- a/src/ov_SC03_031/ov_SC03_031_o0c.c +++ b/src/ov_SC03_031/ov_SC03_031_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_089/ov_SC03_089.c b/src/ov_SC03_089/ov_SC03_089.c index f358d03e99..aa6e317e38 100644 --- a/src/ov_SC03_089/ov_SC03_089.c +++ b/src/ov_SC03_089/ov_SC03_089.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_089/ov_SC03_089_after.c b/src/ov_SC03_089/ov_SC03_089_after.c index 289867da14..14d500763d 100644 --- a/src/ov_SC03_089/ov_SC03_089_after.c +++ b/src/ov_SC03_089/ov_SC03_089_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_089/ov_SC03_089_jr_8012ACE0.c b/src/ov_SC03_089/ov_SC03_089_jr_8012ACE0.c index d5065b5bf2..ccd41cec4c 100644 --- a/src/ov_SC03_089/ov_SC03_089_jr_8012ACE0.c +++ b/src/ov_SC03_089/ov_SC03_089_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_089/ov_SC03_089_jr_80135D20.c b/src/ov_SC03_089/ov_SC03_089_jr_80135D20.c index 9281bc603f..5363a6e09a 100644 --- a/src/ov_SC03_089/ov_SC03_089_jr_80135D20.c +++ b/src/ov_SC03_089/ov_SC03_089_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_089/ov_SC03_089_jr_801380E0.c b/src/ov_SC03_089/ov_SC03_089_jr_801380E0.c index 26811cab66..194d4abd8a 100644 --- a/src/ov_SC03_089/ov_SC03_089_jr_801380E0.c +++ b/src/ov_SC03_089/ov_SC03_089_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 5495ac2b8a..a61d16454a 100644 --- a/src/ov_SC03_089/ov_SC03_089_jr_8015AE2C.c +++ b/src/ov_SC03_089/ov_SC03_089_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_089/ov_SC03_089_jr_8015C32C.c b/src/ov_SC03_089/ov_SC03_089_jr_8015C32C.c index df7510b109..da6a207626 100644 --- a/src/ov_SC03_089/ov_SC03_089_jr_8015C32C.c +++ b/src/ov_SC03_089/ov_SC03_089_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_089/ov_SC03_089_jr_8016AB6C.c b/src/ov_SC03_089/ov_SC03_089_jr_8016AB6C.c index ded3a04161..fce0c02e6a 100644 --- a/src/ov_SC03_089/ov_SC03_089_jr_8016AB6C.c +++ b/src/ov_SC03_089/ov_SC03_089_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_089/ov_SC03_089_jr_80171B4C.c b/src/ov_SC03_089/ov_SC03_089_jr_80171B4C.c index 20dcba9129..0ad5d718af 100644 --- a/src/ov_SC03_089/ov_SC03_089_jr_80171B4C.c +++ b/src/ov_SC03_089/ov_SC03_089_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_089/ov_SC03_089_jr_801734BC.c b/src/ov_SC03_089/ov_SC03_089_jr_801734BC.c index 4d63676d33..071e4fc8e4 100644 --- a/src/ov_SC03_089/ov_SC03_089_jr_801734BC.c +++ b/src/ov_SC03_089/ov_SC03_089_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_089/ov_SC03_089_o0c.c b/src/ov_SC03_089/ov_SC03_089_o0c.c index 26ae2a961c..5d6db4117b 100644 --- a/src/ov_SC03_089/ov_SC03_089_o0c.c +++ b/src/ov_SC03_089/ov_SC03_089_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_090/ov_SC03_090.c b/src/ov_SC03_090/ov_SC03_090.c index 6395c32ec0..080c26e4f0 100644 --- a/src/ov_SC03_090/ov_SC03_090.c +++ b/src/ov_SC03_090/ov_SC03_090.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_090/ov_SC03_090_after.c b/src/ov_SC03_090/ov_SC03_090_after.c index 57bab87af4..771bd00228 100644 --- a/src/ov_SC03_090/ov_SC03_090_after.c +++ b/src/ov_SC03_090/ov_SC03_090_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_090/ov_SC03_090_jr_8012ACE0.c b/src/ov_SC03_090/ov_SC03_090_jr_8012ACE0.c index 1e5941769a..9e87760c95 100644 --- a/src/ov_SC03_090/ov_SC03_090_jr_8012ACE0.c +++ b/src/ov_SC03_090/ov_SC03_090_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_090/ov_SC03_090_jr_80135D20.c b/src/ov_SC03_090/ov_SC03_090_jr_80135D20.c index cc31f86445..2eca424e33 100644 --- a/src/ov_SC03_090/ov_SC03_090_jr_80135D20.c +++ b/src/ov_SC03_090/ov_SC03_090_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_090/ov_SC03_090_jr_801380E0.c b/src/ov_SC03_090/ov_SC03_090_jr_801380E0.c index 3cbf6011b5..350432c452 100644 --- a/src/ov_SC03_090/ov_SC03_090_jr_801380E0.c +++ b/src/ov_SC03_090/ov_SC03_090_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 faf8daddd8..20fa3fd78a 100644 --- a/src/ov_SC03_090/ov_SC03_090_jr_8015AE2C.c +++ b/src/ov_SC03_090/ov_SC03_090_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_090/ov_SC03_090_jr_8015C32C.c b/src/ov_SC03_090/ov_SC03_090_jr_8015C32C.c index 1ddd705acb..5b55fe5c9e 100644 --- a/src/ov_SC03_090/ov_SC03_090_jr_8015C32C.c +++ b/src/ov_SC03_090/ov_SC03_090_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_090/ov_SC03_090_jr_8016AB6C.c b/src/ov_SC03_090/ov_SC03_090_jr_8016AB6C.c index 57c0cbbcfe..5721779d9b 100644 --- a/src/ov_SC03_090/ov_SC03_090_jr_8016AB6C.c +++ b/src/ov_SC03_090/ov_SC03_090_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_090/ov_SC03_090_jr_80171B4C.c b/src/ov_SC03_090/ov_SC03_090_jr_80171B4C.c index 012b79cee7..7933703080 100644 --- a/src/ov_SC03_090/ov_SC03_090_jr_80171B4C.c +++ b/src/ov_SC03_090/ov_SC03_090_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_090/ov_SC03_090_jr_801734BC.c b/src/ov_SC03_090/ov_SC03_090_jr_801734BC.c index f939e12581..4b44492df3 100644 --- a/src/ov_SC03_090/ov_SC03_090_jr_801734BC.c +++ b/src/ov_SC03_090/ov_SC03_090_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_090/ov_SC03_090_o0c.c b/src/ov_SC03_090/ov_SC03_090_o0c.c index e5e9e5c4e5..c1d98c4f36 100644 --- a/src/ov_SC03_090/ov_SC03_090_o0c.c +++ b/src/ov_SC03_090/ov_SC03_090_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_091/ov_SC03_091.c b/src/ov_SC03_091/ov_SC03_091.c index f4e6986584..d96eb09bef 100644 --- a/src/ov_SC03_091/ov_SC03_091.c +++ b/src/ov_SC03_091/ov_SC03_091.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_091/ov_SC03_091_after.c b/src/ov_SC03_091/ov_SC03_091_after.c index 2c96122d6c..002ae0e432 100644 --- a/src/ov_SC03_091/ov_SC03_091_after.c +++ b/src/ov_SC03_091/ov_SC03_091_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_091/ov_SC03_091_jr_8012ACE0.c b/src/ov_SC03_091/ov_SC03_091_jr_8012ACE0.c index 79ed575f0e..234d6fd8bc 100644 --- a/src/ov_SC03_091/ov_SC03_091_jr_8012ACE0.c +++ b/src/ov_SC03_091/ov_SC03_091_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_091/ov_SC03_091_jr_80135D20.c b/src/ov_SC03_091/ov_SC03_091_jr_80135D20.c index f7232c87b2..b786b787d3 100644 --- a/src/ov_SC03_091/ov_SC03_091_jr_80135D20.c +++ b/src/ov_SC03_091/ov_SC03_091_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_091/ov_SC03_091_jr_801380E0.c b/src/ov_SC03_091/ov_SC03_091_jr_801380E0.c index 03b5561118..0a669c0fd6 100644 --- a/src/ov_SC03_091/ov_SC03_091_jr_801380E0.c +++ b/src/ov_SC03_091/ov_SC03_091_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 834f746002..218b621bc5 100644 --- a/src/ov_SC03_091/ov_SC03_091_jr_8015AE2C.c +++ b/src/ov_SC03_091/ov_SC03_091_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_091/ov_SC03_091_jr_8015C32C.c b/src/ov_SC03_091/ov_SC03_091_jr_8015C32C.c index 102624cdbc..0e1e7f1bb4 100644 --- a/src/ov_SC03_091/ov_SC03_091_jr_8015C32C.c +++ b/src/ov_SC03_091/ov_SC03_091_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_091/ov_SC03_091_jr_8016AB6C.c b/src/ov_SC03_091/ov_SC03_091_jr_8016AB6C.c index 89919bb496..dc323665f4 100644 --- a/src/ov_SC03_091/ov_SC03_091_jr_8016AB6C.c +++ b/src/ov_SC03_091/ov_SC03_091_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_091/ov_SC03_091_jr_80171B4C.c b/src/ov_SC03_091/ov_SC03_091_jr_80171B4C.c index 05eac658d5..72337c7131 100644 --- a/src/ov_SC03_091/ov_SC03_091_jr_80171B4C.c +++ b/src/ov_SC03_091/ov_SC03_091_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_091/ov_SC03_091_jr_801734BC.c b/src/ov_SC03_091/ov_SC03_091_jr_801734BC.c index a64a8aca6b..652e3c5db9 100644 --- a/src/ov_SC03_091/ov_SC03_091_jr_801734BC.c +++ b/src/ov_SC03_091/ov_SC03_091_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_091/ov_SC03_091_o0c.c b/src/ov_SC03_091/ov_SC03_091_o0c.c index 19c830f687..d76e6f8c99 100644 --- a/src/ov_SC03_091/ov_SC03_091_o0c.c +++ b/src/ov_SC03_091/ov_SC03_091_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_092/ov_SC03_092.c b/src/ov_SC03_092/ov_SC03_092.c index 3ab0b5e3e4..e027e0a709 100644 --- a/src/ov_SC03_092/ov_SC03_092.c +++ b/src/ov_SC03_092/ov_SC03_092.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_092/ov_SC03_092_after.c b/src/ov_SC03_092/ov_SC03_092_after.c index 965726532b..f137dd7e7e 100644 --- a/src/ov_SC03_092/ov_SC03_092_after.c +++ b/src/ov_SC03_092/ov_SC03_092_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_092/ov_SC03_092_jr_8012ACE0.c b/src/ov_SC03_092/ov_SC03_092_jr_8012ACE0.c index c349d1c8ff..e565ddf6b8 100644 --- a/src/ov_SC03_092/ov_SC03_092_jr_8012ACE0.c +++ b/src/ov_SC03_092/ov_SC03_092_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_092/ov_SC03_092_jr_80135D20.c b/src/ov_SC03_092/ov_SC03_092_jr_80135D20.c index 204234f890..780bb71b48 100644 --- a/src/ov_SC03_092/ov_SC03_092_jr_80135D20.c +++ b/src/ov_SC03_092/ov_SC03_092_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_092/ov_SC03_092_jr_801380E0.c b/src/ov_SC03_092/ov_SC03_092_jr_801380E0.c index 6105578adf..d6be87224b 100644 --- a/src/ov_SC03_092/ov_SC03_092_jr_801380E0.c +++ b/src/ov_SC03_092/ov_SC03_092_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 4bd8d6d1d6..0546c36bc1 100644 --- a/src/ov_SC03_092/ov_SC03_092_jr_8015AE2C.c +++ b/src/ov_SC03_092/ov_SC03_092_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_092/ov_SC03_092_jr_8015C32C.c b/src/ov_SC03_092/ov_SC03_092_jr_8015C32C.c index 397e68593c..bd34960fbd 100644 --- a/src/ov_SC03_092/ov_SC03_092_jr_8015C32C.c +++ b/src/ov_SC03_092/ov_SC03_092_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_092/ov_SC03_092_jr_8016AB6C.c b/src/ov_SC03_092/ov_SC03_092_jr_8016AB6C.c index c62b92b814..a9a3af9e34 100644 --- a/src/ov_SC03_092/ov_SC03_092_jr_8016AB6C.c +++ b/src/ov_SC03_092/ov_SC03_092_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_092/ov_SC03_092_jr_80171B4C.c b/src/ov_SC03_092/ov_SC03_092_jr_80171B4C.c index 84badf2d6e..d7638ec356 100644 --- a/src/ov_SC03_092/ov_SC03_092_jr_80171B4C.c +++ b/src/ov_SC03_092/ov_SC03_092_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_092/ov_SC03_092_jr_801734BC.c b/src/ov_SC03_092/ov_SC03_092_jr_801734BC.c index 25fdb2f0f0..4414b4271e 100644 --- a/src/ov_SC03_092/ov_SC03_092_jr_801734BC.c +++ b/src/ov_SC03_092/ov_SC03_092_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_092/ov_SC03_092_o0c.c b/src/ov_SC03_092/ov_SC03_092_o0c.c index 0e1d381316..886337a099 100644 --- a/src/ov_SC03_092/ov_SC03_092_o0c.c +++ b/src/ov_SC03_092/ov_SC03_092_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_093/ov_SC03_093.c b/src/ov_SC03_093/ov_SC03_093.c index 7031c2e727..27647042e6 100644 --- a/src/ov_SC03_093/ov_SC03_093.c +++ b/src/ov_SC03_093/ov_SC03_093.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_093/ov_SC03_093_after.c b/src/ov_SC03_093/ov_SC03_093_after.c index 6b63f49e12..266a146e61 100644 --- a/src/ov_SC03_093/ov_SC03_093_after.c +++ b/src/ov_SC03_093/ov_SC03_093_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_093/ov_SC03_093_jr_8012ACE0.c b/src/ov_SC03_093/ov_SC03_093_jr_8012ACE0.c index 551afd4f98..1c2e01200e 100644 --- a/src/ov_SC03_093/ov_SC03_093_jr_8012ACE0.c +++ b/src/ov_SC03_093/ov_SC03_093_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_093/ov_SC03_093_jr_80135D20.c b/src/ov_SC03_093/ov_SC03_093_jr_80135D20.c index 7db59eb77f..231e9b6e35 100644 --- a/src/ov_SC03_093/ov_SC03_093_jr_80135D20.c +++ b/src/ov_SC03_093/ov_SC03_093_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_093/ov_SC03_093_jr_801380E0.c b/src/ov_SC03_093/ov_SC03_093_jr_801380E0.c index 233982be9b..c3e390d506 100644 --- a/src/ov_SC03_093/ov_SC03_093_jr_801380E0.c +++ b/src/ov_SC03_093/ov_SC03_093_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 984ec2bdf8..cf365b808a 100644 --- a/src/ov_SC03_093/ov_SC03_093_jr_8015AE2C.c +++ b/src/ov_SC03_093/ov_SC03_093_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_093/ov_SC03_093_jr_8015C32C.c b/src/ov_SC03_093/ov_SC03_093_jr_8015C32C.c index c003feb657..25c77e931b 100644 --- a/src/ov_SC03_093/ov_SC03_093_jr_8015C32C.c +++ b/src/ov_SC03_093/ov_SC03_093_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_093/ov_SC03_093_jr_8016AB6C.c b/src/ov_SC03_093/ov_SC03_093_jr_8016AB6C.c index 22bfa17c42..6d402a39e5 100644 --- a/src/ov_SC03_093/ov_SC03_093_jr_8016AB6C.c +++ b/src/ov_SC03_093/ov_SC03_093_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_093/ov_SC03_093_jr_80171B4C.c b/src/ov_SC03_093/ov_SC03_093_jr_80171B4C.c index 0d917153bf..ebc265f8a9 100644 --- a/src/ov_SC03_093/ov_SC03_093_jr_80171B4C.c +++ b/src/ov_SC03_093/ov_SC03_093_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_093/ov_SC03_093_jr_801734BC.c b/src/ov_SC03_093/ov_SC03_093_jr_801734BC.c index f5af236765..81245ff413 100644 --- a/src/ov_SC03_093/ov_SC03_093_jr_801734BC.c +++ b/src/ov_SC03_093/ov_SC03_093_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_093/ov_SC03_093_o0c.c b/src/ov_SC03_093/ov_SC03_093_o0c.c index c089bf7d68..c9f6429086 100644 --- a/src/ov_SC03_093/ov_SC03_093_o0c.c +++ b/src/ov_SC03_093/ov_SC03_093_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_094/ov_SC03_094.c b/src/ov_SC03_094/ov_SC03_094.c index 430bd6bed0..c766cf6062 100644 --- a/src/ov_SC03_094/ov_SC03_094.c +++ b/src/ov_SC03_094/ov_SC03_094.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_094/ov_SC03_094_after.c b/src/ov_SC03_094/ov_SC03_094_after.c index ca22632564..39290a5b04 100644 --- a/src/ov_SC03_094/ov_SC03_094_after.c +++ b/src/ov_SC03_094/ov_SC03_094_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_094/ov_SC03_094_jr_8012ACE0.c b/src/ov_SC03_094/ov_SC03_094_jr_8012ACE0.c index 2aa33c5f68..7cdc7597e3 100644 --- a/src/ov_SC03_094/ov_SC03_094_jr_8012ACE0.c +++ b/src/ov_SC03_094/ov_SC03_094_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_094/ov_SC03_094_jr_80135D20.c b/src/ov_SC03_094/ov_SC03_094_jr_80135D20.c index 56334275b8..f61ece16e7 100644 --- a/src/ov_SC03_094/ov_SC03_094_jr_80135D20.c +++ b/src/ov_SC03_094/ov_SC03_094_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_094/ov_SC03_094_jr_801380E0.c b/src/ov_SC03_094/ov_SC03_094_jr_801380E0.c index 9d330ea54a..67db69603f 100644 --- a/src/ov_SC03_094/ov_SC03_094_jr_801380E0.c +++ b/src/ov_SC03_094/ov_SC03_094_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 75e13ffa3f..36747f57ec 100644 --- a/src/ov_SC03_094/ov_SC03_094_jr_8015AE2C.c +++ b/src/ov_SC03_094/ov_SC03_094_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_094/ov_SC03_094_jr_8015C32C.c b/src/ov_SC03_094/ov_SC03_094_jr_8015C32C.c index 563b8bd2e3..bf872b65ed 100644 --- a/src/ov_SC03_094/ov_SC03_094_jr_8015C32C.c +++ b/src/ov_SC03_094/ov_SC03_094_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_094/ov_SC03_094_jr_8016AB6C.c b/src/ov_SC03_094/ov_SC03_094_jr_8016AB6C.c index 1d0ac27a67..3cd7d76dba 100644 --- a/src/ov_SC03_094/ov_SC03_094_jr_8016AB6C.c +++ b/src/ov_SC03_094/ov_SC03_094_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_094/ov_SC03_094_jr_80171B4C.c b/src/ov_SC03_094/ov_SC03_094_jr_80171B4C.c index 8f5dcca2d0..8053b5de76 100644 --- a/src/ov_SC03_094/ov_SC03_094_jr_80171B4C.c +++ b/src/ov_SC03_094/ov_SC03_094_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_094/ov_SC03_094_jr_801734BC.c b/src/ov_SC03_094/ov_SC03_094_jr_801734BC.c index 05496c804d..ce98083922 100644 --- a/src/ov_SC03_094/ov_SC03_094_jr_801734BC.c +++ b/src/ov_SC03_094/ov_SC03_094_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_094/ov_SC03_094_o0c.c b/src/ov_SC03_094/ov_SC03_094_o0c.c index a9b6b91b09..c44d5fd91f 100644 --- a/src/ov_SC03_094/ov_SC03_094_o0c.c +++ b/src/ov_SC03_094/ov_SC03_094_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_095/ov_SC03_095.c b/src/ov_SC03_095/ov_SC03_095.c index 0b2c1f1c95..b09771c386 100644 --- a/src/ov_SC03_095/ov_SC03_095.c +++ b/src/ov_SC03_095/ov_SC03_095.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_095/ov_SC03_095_after.c b/src/ov_SC03_095/ov_SC03_095_after.c index 93d16f739e..86143e7e55 100644 --- a/src/ov_SC03_095/ov_SC03_095_after.c +++ b/src/ov_SC03_095/ov_SC03_095_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_095/ov_SC03_095_jr_8012ACE0.c b/src/ov_SC03_095/ov_SC03_095_jr_8012ACE0.c index 452b6d3e63..7f0cd4f27c 100644 --- a/src/ov_SC03_095/ov_SC03_095_jr_8012ACE0.c +++ b/src/ov_SC03_095/ov_SC03_095_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_095/ov_SC03_095_jr_80135D20.c b/src/ov_SC03_095/ov_SC03_095_jr_80135D20.c index e4adb85e57..97e0f5c1b2 100644 --- a/src/ov_SC03_095/ov_SC03_095_jr_80135D20.c +++ b/src/ov_SC03_095/ov_SC03_095_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_095/ov_SC03_095_jr_801380E0.c b/src/ov_SC03_095/ov_SC03_095_jr_801380E0.c index fdc53ab970..9a84a614fc 100644 --- a/src/ov_SC03_095/ov_SC03_095_jr_801380E0.c +++ b/src/ov_SC03_095/ov_SC03_095_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 d26b96c7ad..4af8bf4094 100644 --- a/src/ov_SC03_095/ov_SC03_095_jr_8015AE2C.c +++ b/src/ov_SC03_095/ov_SC03_095_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_095/ov_SC03_095_jr_8015C32C.c b/src/ov_SC03_095/ov_SC03_095_jr_8015C32C.c index cc75538074..50686c0ef1 100644 --- a/src/ov_SC03_095/ov_SC03_095_jr_8015C32C.c +++ b/src/ov_SC03_095/ov_SC03_095_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_095/ov_SC03_095_jr_8016AB6C.c b/src/ov_SC03_095/ov_SC03_095_jr_8016AB6C.c index 51cae363df..12d560a922 100644 --- a/src/ov_SC03_095/ov_SC03_095_jr_8016AB6C.c +++ b/src/ov_SC03_095/ov_SC03_095_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_095/ov_SC03_095_jr_80171B4C.c b/src/ov_SC03_095/ov_SC03_095_jr_80171B4C.c index b5be24942a..d39b932c28 100644 --- a/src/ov_SC03_095/ov_SC03_095_jr_80171B4C.c +++ b/src/ov_SC03_095/ov_SC03_095_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_095/ov_SC03_095_jr_801734BC.c b/src/ov_SC03_095/ov_SC03_095_jr_801734BC.c index 894fe661e9..e0a7630446 100644 --- a/src/ov_SC03_095/ov_SC03_095_jr_801734BC.c +++ b/src/ov_SC03_095/ov_SC03_095_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_095/ov_SC03_095_o0c.c b/src/ov_SC03_095/ov_SC03_095_o0c.c index 87313e2be6..87f4b59092 100644 --- a/src/ov_SC03_095/ov_SC03_095_o0c.c +++ b/src/ov_SC03_095/ov_SC03_095_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_096/ov_SC03_096.c b/src/ov_SC03_096/ov_SC03_096.c index 24a22ce1b7..ff3c4da105 100644 --- a/src/ov_SC03_096/ov_SC03_096.c +++ b/src/ov_SC03_096/ov_SC03_096.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_096/ov_SC03_096_after.c b/src/ov_SC03_096/ov_SC03_096_after.c index 6b2b49f04c..876aa67bc7 100644 --- a/src/ov_SC03_096/ov_SC03_096_after.c +++ b/src/ov_SC03_096/ov_SC03_096_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_096/ov_SC03_096_jr_8012ACE0.c b/src/ov_SC03_096/ov_SC03_096_jr_8012ACE0.c index dfc2e2865c..3785d1f7b0 100644 --- a/src/ov_SC03_096/ov_SC03_096_jr_8012ACE0.c +++ b/src/ov_SC03_096/ov_SC03_096_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_096/ov_SC03_096_jr_80135D20.c b/src/ov_SC03_096/ov_SC03_096_jr_80135D20.c index 54d9e3ec8b..19a610bcd2 100644 --- a/src/ov_SC03_096/ov_SC03_096_jr_80135D20.c +++ b/src/ov_SC03_096/ov_SC03_096_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_096/ov_SC03_096_jr_801380E0.c b/src/ov_SC03_096/ov_SC03_096_jr_801380E0.c index 8a78649df0..1f76f7484d 100644 --- a/src/ov_SC03_096/ov_SC03_096_jr_801380E0.c +++ b/src/ov_SC03_096/ov_SC03_096_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 48d9c575ab..1d8d97fde0 100644 --- a/src/ov_SC03_096/ov_SC03_096_jr_8015AE2C.c +++ b/src/ov_SC03_096/ov_SC03_096_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_096/ov_SC03_096_jr_8015C32C.c b/src/ov_SC03_096/ov_SC03_096_jr_8015C32C.c index 2cdcfa75b2..c4f66bf3a5 100644 --- a/src/ov_SC03_096/ov_SC03_096_jr_8015C32C.c +++ b/src/ov_SC03_096/ov_SC03_096_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_096/ov_SC03_096_jr_8016AB6C.c b/src/ov_SC03_096/ov_SC03_096_jr_8016AB6C.c index 4aa3806a22..5e7dcf9f92 100644 --- a/src/ov_SC03_096/ov_SC03_096_jr_8016AB6C.c +++ b/src/ov_SC03_096/ov_SC03_096_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_096/ov_SC03_096_jr_80171B4C.c b/src/ov_SC03_096/ov_SC03_096_jr_80171B4C.c index 75a8238d7b..800985ef4c 100644 --- a/src/ov_SC03_096/ov_SC03_096_jr_80171B4C.c +++ b/src/ov_SC03_096/ov_SC03_096_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_096/ov_SC03_096_jr_801734BC.c b/src/ov_SC03_096/ov_SC03_096_jr_801734BC.c index f013d3afba..78fb0e28ea 100644 --- a/src/ov_SC03_096/ov_SC03_096_jr_801734BC.c +++ b/src/ov_SC03_096/ov_SC03_096_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_096/ov_SC03_096_o0c.c b/src/ov_SC03_096/ov_SC03_096_o0c.c index 049714ef7c..cdf8b7b81a 100644 --- a/src/ov_SC03_096/ov_SC03_096_o0c.c +++ b/src/ov_SC03_096/ov_SC03_096_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_097/ov_SC03_097.c b/src/ov_SC03_097/ov_SC03_097.c index 1e5312d44f..f907c41ae4 100644 --- a/src/ov_SC03_097/ov_SC03_097.c +++ b/src/ov_SC03_097/ov_SC03_097.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_097/ov_SC03_097_after.c b/src/ov_SC03_097/ov_SC03_097_after.c index 70a8dfb21b..8b2cc2d137 100644 --- a/src/ov_SC03_097/ov_SC03_097_after.c +++ b/src/ov_SC03_097/ov_SC03_097_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_097/ov_SC03_097_jr_8012ACE0.c b/src/ov_SC03_097/ov_SC03_097_jr_8012ACE0.c index 0b64cacf54..126cebeb5a 100644 --- a/src/ov_SC03_097/ov_SC03_097_jr_8012ACE0.c +++ b/src/ov_SC03_097/ov_SC03_097_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_097/ov_SC03_097_jr_80135D20.c b/src/ov_SC03_097/ov_SC03_097_jr_80135D20.c index b569283f4a..01292ceff2 100644 --- a/src/ov_SC03_097/ov_SC03_097_jr_80135D20.c +++ b/src/ov_SC03_097/ov_SC03_097_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_097/ov_SC03_097_jr_801380E0.c b/src/ov_SC03_097/ov_SC03_097_jr_801380E0.c index c0d5f9f8c7..85b789c945 100644 --- a/src/ov_SC03_097/ov_SC03_097_jr_801380E0.c +++ b/src/ov_SC03_097/ov_SC03_097_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 94045e3360..01651d1796 100644 --- a/src/ov_SC03_097/ov_SC03_097_jr_8015AE2C.c +++ b/src/ov_SC03_097/ov_SC03_097_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_097/ov_SC03_097_jr_8015C32C.c b/src/ov_SC03_097/ov_SC03_097_jr_8015C32C.c index cedb7b9c35..a393ca995c 100644 --- a/src/ov_SC03_097/ov_SC03_097_jr_8015C32C.c +++ b/src/ov_SC03_097/ov_SC03_097_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_097/ov_SC03_097_jr_8016AB6C.c b/src/ov_SC03_097/ov_SC03_097_jr_8016AB6C.c index 0cdb196296..fd949f8134 100644 --- a/src/ov_SC03_097/ov_SC03_097_jr_8016AB6C.c +++ b/src/ov_SC03_097/ov_SC03_097_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_097/ov_SC03_097_jr_80171B4C.c b/src/ov_SC03_097/ov_SC03_097_jr_80171B4C.c index 515df20a88..689133a95f 100644 --- a/src/ov_SC03_097/ov_SC03_097_jr_80171B4C.c +++ b/src/ov_SC03_097/ov_SC03_097_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_097/ov_SC03_097_jr_801734BC.c b/src/ov_SC03_097/ov_SC03_097_jr_801734BC.c index b2fa5895b1..114b3d7728 100644 --- a/src/ov_SC03_097/ov_SC03_097_jr_801734BC.c +++ b/src/ov_SC03_097/ov_SC03_097_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_097/ov_SC03_097_o0c.c b/src/ov_SC03_097/ov_SC03_097_o0c.c index 9eaa7a83e1..183dbc96e3 100644 --- a/src/ov_SC03_097/ov_SC03_097_o0c.c +++ b/src/ov_SC03_097/ov_SC03_097_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_098/ov_SC03_098.c b/src/ov_SC03_098/ov_SC03_098.c index e0f4189868..6e973ffbc7 100644 --- a/src/ov_SC03_098/ov_SC03_098.c +++ b/src/ov_SC03_098/ov_SC03_098.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_098/ov_SC03_098_after.c b/src/ov_SC03_098/ov_SC03_098_after.c index bd513926ea..9bec193f77 100644 --- a/src/ov_SC03_098/ov_SC03_098_after.c +++ b/src/ov_SC03_098/ov_SC03_098_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_098/ov_SC03_098_jr_8012ACE0.c b/src/ov_SC03_098/ov_SC03_098_jr_8012ACE0.c index ee27ca83bd..7b11b34bcc 100644 --- a/src/ov_SC03_098/ov_SC03_098_jr_8012ACE0.c +++ b/src/ov_SC03_098/ov_SC03_098_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_098/ov_SC03_098_jr_80135D20.c b/src/ov_SC03_098/ov_SC03_098_jr_80135D20.c index c16b7325e0..0bcb3107be 100644 --- a/src/ov_SC03_098/ov_SC03_098_jr_80135D20.c +++ b/src/ov_SC03_098/ov_SC03_098_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_098/ov_SC03_098_jr_801380E0.c b/src/ov_SC03_098/ov_SC03_098_jr_801380E0.c index e401198a38..e8ca6ba92c 100644 --- a/src/ov_SC03_098/ov_SC03_098_jr_801380E0.c +++ b/src/ov_SC03_098/ov_SC03_098_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 bf0b695b2f..30c91da0e0 100644 --- a/src/ov_SC03_098/ov_SC03_098_jr_8015AE2C.c +++ b/src/ov_SC03_098/ov_SC03_098_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_098/ov_SC03_098_jr_8015C32C.c b/src/ov_SC03_098/ov_SC03_098_jr_8015C32C.c index fdbdae5318..2f99251829 100644 --- a/src/ov_SC03_098/ov_SC03_098_jr_8015C32C.c +++ b/src/ov_SC03_098/ov_SC03_098_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_098/ov_SC03_098_jr_8016AB6C.c b/src/ov_SC03_098/ov_SC03_098_jr_8016AB6C.c index 4f1ce1b7d2..9ef5eb7ac0 100644 --- a/src/ov_SC03_098/ov_SC03_098_jr_8016AB6C.c +++ b/src/ov_SC03_098/ov_SC03_098_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_098/ov_SC03_098_jr_80171B4C.c b/src/ov_SC03_098/ov_SC03_098_jr_80171B4C.c index 2971dc9d94..702d82745c 100644 --- a/src/ov_SC03_098/ov_SC03_098_jr_80171B4C.c +++ b/src/ov_SC03_098/ov_SC03_098_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_098/ov_SC03_098_jr_801734BC.c b/src/ov_SC03_098/ov_SC03_098_jr_801734BC.c index 5c546b5d44..9acd660fb1 100644 --- a/src/ov_SC03_098/ov_SC03_098_jr_801734BC.c +++ b/src/ov_SC03_098/ov_SC03_098_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_098/ov_SC03_098_o0c.c b/src/ov_SC03_098/ov_SC03_098_o0c.c index 15daf4a462..e4d136b527 100644 --- a/src/ov_SC03_098/ov_SC03_098_o0c.c +++ b/src/ov_SC03_098/ov_SC03_098_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_099/ov_SC03_099.c b/src/ov_SC03_099/ov_SC03_099.c index a179a4093a..b6ca9c832c 100644 --- a/src/ov_SC03_099/ov_SC03_099.c +++ b/src/ov_SC03_099/ov_SC03_099.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_099/ov_SC03_099_after.c b/src/ov_SC03_099/ov_SC03_099_after.c index 6f3516db09..23f54f6831 100644 --- a/src/ov_SC03_099/ov_SC03_099_after.c +++ b/src/ov_SC03_099/ov_SC03_099_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_099/ov_SC03_099_jr_8012ACE0.c b/src/ov_SC03_099/ov_SC03_099_jr_8012ACE0.c index 0b5dce5e4c..ed4252a7c8 100644 --- a/src/ov_SC03_099/ov_SC03_099_jr_8012ACE0.c +++ b/src/ov_SC03_099/ov_SC03_099_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_099/ov_SC03_099_jr_80135D20.c b/src/ov_SC03_099/ov_SC03_099_jr_80135D20.c index a763875e14..5d4176f786 100644 --- a/src/ov_SC03_099/ov_SC03_099_jr_80135D20.c +++ b/src/ov_SC03_099/ov_SC03_099_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_099/ov_SC03_099_jr_801380E0.c b/src/ov_SC03_099/ov_SC03_099_jr_801380E0.c index 240b028906..20b90cdc7e 100644 --- a/src/ov_SC03_099/ov_SC03_099_jr_801380E0.c +++ b/src/ov_SC03_099/ov_SC03_099_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 b16d2ebda0..c4fbb19eb8 100644 --- a/src/ov_SC03_099/ov_SC03_099_jr_8015AE2C.c +++ b/src/ov_SC03_099/ov_SC03_099_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_099/ov_SC03_099_jr_8015C32C.c b/src/ov_SC03_099/ov_SC03_099_jr_8015C32C.c index f3ecc05b44..fede0b59ba 100644 --- a/src/ov_SC03_099/ov_SC03_099_jr_8015C32C.c +++ b/src/ov_SC03_099/ov_SC03_099_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c b/src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c index 5213ca5c41..14b10aaf53 100644 --- a/src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c +++ b/src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_099/ov_SC03_099_jr_80171B4C.c b/src/ov_SC03_099/ov_SC03_099_jr_80171B4C.c index 3a7108f2fa..eeeb05c9e8 100644 --- a/src/ov_SC03_099/ov_SC03_099_jr_80171B4C.c +++ b/src/ov_SC03_099/ov_SC03_099_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_099/ov_SC03_099_jr_801734BC.c b/src/ov_SC03_099/ov_SC03_099_jr_801734BC.c index 69b1e3c607..7e85799e79 100644 --- a/src/ov_SC03_099/ov_SC03_099_jr_801734BC.c +++ b/src/ov_SC03_099/ov_SC03_099_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_099/ov_SC03_099_o0c.c b/src/ov_SC03_099/ov_SC03_099_o0c.c index 291ade829c..3f991ddbb0 100644 --- a/src/ov_SC03_099/ov_SC03_099_o0c.c +++ b/src/ov_SC03_099/ov_SC03_099_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_100/ov_SC03_100.c b/src/ov_SC03_100/ov_SC03_100.c index bb87e0caf2..f270906cda 100644 --- a/src/ov_SC03_100/ov_SC03_100.c +++ b/src/ov_SC03_100/ov_SC03_100.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_100/ov_SC03_100_after.c b/src/ov_SC03_100/ov_SC03_100_after.c index 04fd967b31..017c805ab1 100644 --- a/src/ov_SC03_100/ov_SC03_100_after.c +++ b/src/ov_SC03_100/ov_SC03_100_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_100/ov_SC03_100_jr_8012ACE0.c b/src/ov_SC03_100/ov_SC03_100_jr_8012ACE0.c index e9ebab5dee..8cfd6be11c 100644 --- a/src/ov_SC03_100/ov_SC03_100_jr_8012ACE0.c +++ b/src/ov_SC03_100/ov_SC03_100_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_100/ov_SC03_100_jr_80135D20.c b/src/ov_SC03_100/ov_SC03_100_jr_80135D20.c index 711251f7c9..9fba650322 100644 --- a/src/ov_SC03_100/ov_SC03_100_jr_80135D20.c +++ b/src/ov_SC03_100/ov_SC03_100_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_100/ov_SC03_100_jr_801380E0.c b/src/ov_SC03_100/ov_SC03_100_jr_801380E0.c index 7efd03cc60..52a5aafe51 100644 --- a/src/ov_SC03_100/ov_SC03_100_jr_801380E0.c +++ b/src/ov_SC03_100/ov_SC03_100_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 bd8eaf0e38..7ceae23f21 100644 --- a/src/ov_SC03_100/ov_SC03_100_jr_8015AE2C.c +++ b/src/ov_SC03_100/ov_SC03_100_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_100/ov_SC03_100_jr_8015C32C.c b/src/ov_SC03_100/ov_SC03_100_jr_8015C32C.c index 03b35b64aa..c7e5eefce0 100644 --- a/src/ov_SC03_100/ov_SC03_100_jr_8015C32C.c +++ b/src/ov_SC03_100/ov_SC03_100_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_100/ov_SC03_100_jr_8016AB6C.c b/src/ov_SC03_100/ov_SC03_100_jr_8016AB6C.c index dd53feced5..9cc67a2754 100644 --- a/src/ov_SC03_100/ov_SC03_100_jr_8016AB6C.c +++ b/src/ov_SC03_100/ov_SC03_100_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_100/ov_SC03_100_jr_80171B4C.c b/src/ov_SC03_100/ov_SC03_100_jr_80171B4C.c index d21e5e2046..2bdf27b0b5 100644 --- a/src/ov_SC03_100/ov_SC03_100_jr_80171B4C.c +++ b/src/ov_SC03_100/ov_SC03_100_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_100/ov_SC03_100_jr_801734BC.c b/src/ov_SC03_100/ov_SC03_100_jr_801734BC.c index 4fcb9a221a..067d4088f2 100644 --- a/src/ov_SC03_100/ov_SC03_100_jr_801734BC.c +++ b/src/ov_SC03_100/ov_SC03_100_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_100/ov_SC03_100_o0c.c b/src/ov_SC03_100/ov_SC03_100_o0c.c index 472874310b..e03471b99f 100644 --- a/src/ov_SC03_100/ov_SC03_100_o0c.c +++ b/src/ov_SC03_100/ov_SC03_100_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_101/ov_SC03_101.c b/src/ov_SC03_101/ov_SC03_101.c index ccd0413e26..f27079efe8 100644 --- a/src/ov_SC03_101/ov_SC03_101.c +++ b/src/ov_SC03_101/ov_SC03_101.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_101/ov_SC03_101_after.c b/src/ov_SC03_101/ov_SC03_101_after.c index 33c16386b3..7e5bba414d 100644 --- a/src/ov_SC03_101/ov_SC03_101_after.c +++ b/src/ov_SC03_101/ov_SC03_101_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_101/ov_SC03_101_jr_8012ACE0.c b/src/ov_SC03_101/ov_SC03_101_jr_8012ACE0.c index f04250c833..c711d2f964 100644 --- a/src/ov_SC03_101/ov_SC03_101_jr_8012ACE0.c +++ b/src/ov_SC03_101/ov_SC03_101_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_101/ov_SC03_101_jr_80135D20.c b/src/ov_SC03_101/ov_SC03_101_jr_80135D20.c index 516e0d787a..80c86c81d3 100644 --- a/src/ov_SC03_101/ov_SC03_101_jr_80135D20.c +++ b/src/ov_SC03_101/ov_SC03_101_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_101/ov_SC03_101_jr_801380E0.c b/src/ov_SC03_101/ov_SC03_101_jr_801380E0.c index 854f5586bf..8cd01b4411 100644 --- a/src/ov_SC03_101/ov_SC03_101_jr_801380E0.c +++ b/src/ov_SC03_101/ov_SC03_101_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 6fad3f8888..b574ee760a 100644 --- a/src/ov_SC03_101/ov_SC03_101_jr_8015AE2C.c +++ b/src/ov_SC03_101/ov_SC03_101_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_101/ov_SC03_101_jr_8015C32C.c b/src/ov_SC03_101/ov_SC03_101_jr_8015C32C.c index ede8ac00c7..eb3495deef 100644 --- a/src/ov_SC03_101/ov_SC03_101_jr_8015C32C.c +++ b/src/ov_SC03_101/ov_SC03_101_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_101/ov_SC03_101_jr_8016AB6C.c b/src/ov_SC03_101/ov_SC03_101_jr_8016AB6C.c index ccf34c0540..1d327ab5b1 100644 --- a/src/ov_SC03_101/ov_SC03_101_jr_8016AB6C.c +++ b/src/ov_SC03_101/ov_SC03_101_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_101/ov_SC03_101_jr_80171B4C.c b/src/ov_SC03_101/ov_SC03_101_jr_80171B4C.c index 3a96796e65..917716a1c0 100644 --- a/src/ov_SC03_101/ov_SC03_101_jr_80171B4C.c +++ b/src/ov_SC03_101/ov_SC03_101_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_101/ov_SC03_101_jr_801734BC.c b/src/ov_SC03_101/ov_SC03_101_jr_801734BC.c index 676518a441..127fec5328 100644 --- a/src/ov_SC03_101/ov_SC03_101_jr_801734BC.c +++ b/src/ov_SC03_101/ov_SC03_101_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_101/ov_SC03_101_o0c.c b/src/ov_SC03_101/ov_SC03_101_o0c.c index 35c2a7bd90..67c40f39b7 100644 --- a/src/ov_SC03_101/ov_SC03_101_o0c.c +++ b/src/ov_SC03_101/ov_SC03_101_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_102/ov_SC03_102.c b/src/ov_SC03_102/ov_SC03_102.c index a942638005..f73aef9d73 100644 --- a/src/ov_SC03_102/ov_SC03_102.c +++ b/src/ov_SC03_102/ov_SC03_102.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_102/ov_SC03_102_after.c b/src/ov_SC03_102/ov_SC03_102_after.c index f51f2bf880..01c02fe187 100644 --- a/src/ov_SC03_102/ov_SC03_102_after.c +++ b/src/ov_SC03_102/ov_SC03_102_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_102/ov_SC03_102_jr_8012ACE0.c b/src/ov_SC03_102/ov_SC03_102_jr_8012ACE0.c index 61da173d06..0a5063154b 100644 --- a/src/ov_SC03_102/ov_SC03_102_jr_8012ACE0.c +++ b/src/ov_SC03_102/ov_SC03_102_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_102/ov_SC03_102_jr_80135D20.c b/src/ov_SC03_102/ov_SC03_102_jr_80135D20.c index 126de5fe47..08e638b0c9 100644 --- a/src/ov_SC03_102/ov_SC03_102_jr_80135D20.c +++ b/src/ov_SC03_102/ov_SC03_102_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_102/ov_SC03_102_jr_801380E0.c b/src/ov_SC03_102/ov_SC03_102_jr_801380E0.c index 50aec09540..af0a48189c 100644 --- a/src/ov_SC03_102/ov_SC03_102_jr_801380E0.c +++ b/src/ov_SC03_102/ov_SC03_102_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 448bb6a88a..628219b857 100644 --- a/src/ov_SC03_102/ov_SC03_102_jr_8015AE2C.c +++ b/src/ov_SC03_102/ov_SC03_102_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_102/ov_SC03_102_jr_8015C32C.c b/src/ov_SC03_102/ov_SC03_102_jr_8015C32C.c index 109ff2972a..5916fd816c 100644 --- a/src/ov_SC03_102/ov_SC03_102_jr_8015C32C.c +++ b/src/ov_SC03_102/ov_SC03_102_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_102/ov_SC03_102_jr_8016AB6C.c b/src/ov_SC03_102/ov_SC03_102_jr_8016AB6C.c index 991ff26b07..0a4b2ce0fd 100644 --- a/src/ov_SC03_102/ov_SC03_102_jr_8016AB6C.c +++ b/src/ov_SC03_102/ov_SC03_102_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_102/ov_SC03_102_jr_80171B4C.c b/src/ov_SC03_102/ov_SC03_102_jr_80171B4C.c index 53486dec3e..7cb0b206c1 100644 --- a/src/ov_SC03_102/ov_SC03_102_jr_80171B4C.c +++ b/src/ov_SC03_102/ov_SC03_102_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_102/ov_SC03_102_jr_801734BC.c b/src/ov_SC03_102/ov_SC03_102_jr_801734BC.c index ed1863b4b9..d66eba22b1 100644 --- a/src/ov_SC03_102/ov_SC03_102_jr_801734BC.c +++ b/src/ov_SC03_102/ov_SC03_102_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_102/ov_SC03_102_o0c.c b/src/ov_SC03_102/ov_SC03_102_o0c.c index 5491981f5e..eaa7605a05 100644 --- a/src/ov_SC03_102/ov_SC03_102_o0c.c +++ b/src/ov_SC03_102/ov_SC03_102_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_103/ov_SC03_103.c b/src/ov_SC03_103/ov_SC03_103.c index 5783796374..c86b3076db 100644 --- a/src/ov_SC03_103/ov_SC03_103.c +++ b/src/ov_SC03_103/ov_SC03_103.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_103/ov_SC03_103_after.c b/src/ov_SC03_103/ov_SC03_103_after.c index 24b22f618f..6b352d26a3 100644 --- a/src/ov_SC03_103/ov_SC03_103_after.c +++ b/src/ov_SC03_103/ov_SC03_103_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_103/ov_SC03_103_jr_8012ACE0.c b/src/ov_SC03_103/ov_SC03_103_jr_8012ACE0.c index 9fada1716b..9a56b250a7 100644 --- a/src/ov_SC03_103/ov_SC03_103_jr_8012ACE0.c +++ b/src/ov_SC03_103/ov_SC03_103_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_103/ov_SC03_103_jr_80135D20.c b/src/ov_SC03_103/ov_SC03_103_jr_80135D20.c index 041901b6bd..a745f76cf1 100644 --- a/src/ov_SC03_103/ov_SC03_103_jr_80135D20.c +++ b/src/ov_SC03_103/ov_SC03_103_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_103/ov_SC03_103_jr_801380E0.c b/src/ov_SC03_103/ov_SC03_103_jr_801380E0.c index 72aa838484..9e4063c0f9 100644 --- a/src/ov_SC03_103/ov_SC03_103_jr_801380E0.c +++ b/src/ov_SC03_103/ov_SC03_103_jr_801380E0.c @@ -1100,43 +1100,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 064a16f504..ff9693010f 100644 --- a/src/ov_SC03_103/ov_SC03_103_jr_8015AE2C.c +++ b/src/ov_SC03_103/ov_SC03_103_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_103/ov_SC03_103_jr_8015C32C.c b/src/ov_SC03_103/ov_SC03_103_jr_8015C32C.c index ffa38acafc..4d6e73c92c 100644 --- a/src/ov_SC03_103/ov_SC03_103_jr_8015C32C.c +++ b/src/ov_SC03_103/ov_SC03_103_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_103/ov_SC03_103_jr_8016AB6C.c b/src/ov_SC03_103/ov_SC03_103_jr_8016AB6C.c index 9859e4a72d..b7dddf1951 100644 --- a/src/ov_SC03_103/ov_SC03_103_jr_8016AB6C.c +++ b/src/ov_SC03_103/ov_SC03_103_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_103/ov_SC03_103_jr_80171B4C.c b/src/ov_SC03_103/ov_SC03_103_jr_80171B4C.c index bd8cca9098..f5ff71fb76 100644 --- a/src/ov_SC03_103/ov_SC03_103_jr_80171B4C.c +++ b/src/ov_SC03_103/ov_SC03_103_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_103/ov_SC03_103_jr_801734BC.c b/src/ov_SC03_103/ov_SC03_103_jr_801734BC.c index 902545dd6b..f808a62634 100644 --- a/src/ov_SC03_103/ov_SC03_103_jr_801734BC.c +++ b/src/ov_SC03_103/ov_SC03_103_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_103/ov_SC03_103_o0c.c b/src/ov_SC03_103/ov_SC03_103_o0c.c index 1dd606c0bc..08b686efe8 100644 --- a/src/ov_SC03_103/ov_SC03_103_o0c.c +++ b/src/ov_SC03_103/ov_SC03_103_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_104/ov_SC03_104.c b/src/ov_SC03_104/ov_SC03_104.c index 9f957316a6..ae51ff1c44 100644 --- a/src/ov_SC03_104/ov_SC03_104.c +++ b/src/ov_SC03_104/ov_SC03_104.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_104/ov_SC03_104_after.c b/src/ov_SC03_104/ov_SC03_104_after.c index fd47f87d7e..de0257bc05 100644 --- a/src/ov_SC03_104/ov_SC03_104_after.c +++ b/src/ov_SC03_104/ov_SC03_104_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_104/ov_SC03_104_jr_8012ACE0.c b/src/ov_SC03_104/ov_SC03_104_jr_8012ACE0.c index 37967778b5..ba8fb42121 100644 --- a/src/ov_SC03_104/ov_SC03_104_jr_8012ACE0.c +++ b/src/ov_SC03_104/ov_SC03_104_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_104/ov_SC03_104_jr_80135D20.c b/src/ov_SC03_104/ov_SC03_104_jr_80135D20.c index 9570ac92da..0aa2295b18 100644 --- a/src/ov_SC03_104/ov_SC03_104_jr_80135D20.c +++ b/src/ov_SC03_104/ov_SC03_104_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_104/ov_SC03_104_jr_801380E0.c b/src/ov_SC03_104/ov_SC03_104_jr_801380E0.c index bbff0bb561..f54d9cd1f3 100644 --- a/src/ov_SC03_104/ov_SC03_104_jr_801380E0.c +++ b/src/ov_SC03_104/ov_SC03_104_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 cee861209a..3a8c272957 100644 --- a/src/ov_SC03_104/ov_SC03_104_jr_8015AE2C.c +++ b/src/ov_SC03_104/ov_SC03_104_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_104/ov_SC03_104_jr_8015C32C.c b/src/ov_SC03_104/ov_SC03_104_jr_8015C32C.c index ba96803069..68cff934b0 100644 --- a/src/ov_SC03_104/ov_SC03_104_jr_8015C32C.c +++ b/src/ov_SC03_104/ov_SC03_104_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_104/ov_SC03_104_jr_8016AB6C.c b/src/ov_SC03_104/ov_SC03_104_jr_8016AB6C.c index 01d4b6dc95..54f27007da 100644 --- a/src/ov_SC03_104/ov_SC03_104_jr_8016AB6C.c +++ b/src/ov_SC03_104/ov_SC03_104_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_104/ov_SC03_104_jr_80171B4C.c b/src/ov_SC03_104/ov_SC03_104_jr_80171B4C.c index 3ccbc64796..de088b3a28 100644 --- a/src/ov_SC03_104/ov_SC03_104_jr_80171B4C.c +++ b/src/ov_SC03_104/ov_SC03_104_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_104/ov_SC03_104_jr_801734BC.c b/src/ov_SC03_104/ov_SC03_104_jr_801734BC.c index ee5312a155..fb506ce8d4 100644 --- a/src/ov_SC03_104/ov_SC03_104_jr_801734BC.c +++ b/src/ov_SC03_104/ov_SC03_104_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_104/ov_SC03_104_o0c.c b/src/ov_SC03_104/ov_SC03_104_o0c.c index a208559e2e..575250df15 100644 --- a/src/ov_SC03_104/ov_SC03_104_o0c.c +++ b/src/ov_SC03_104/ov_SC03_104_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_105/ov_SC03_105.c b/src/ov_SC03_105/ov_SC03_105.c index 8dd9816bba..e953ba09d9 100644 --- a/src/ov_SC03_105/ov_SC03_105.c +++ b/src/ov_SC03_105/ov_SC03_105.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_105/ov_SC03_105_after.c b/src/ov_SC03_105/ov_SC03_105_after.c index 764b52a61c..f1cb48c600 100644 --- a/src/ov_SC03_105/ov_SC03_105_after.c +++ b/src/ov_SC03_105/ov_SC03_105_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_105/ov_SC03_105_jr_8012ACE0.c b/src/ov_SC03_105/ov_SC03_105_jr_8012ACE0.c index 43460c716a..08a9250c2e 100644 --- a/src/ov_SC03_105/ov_SC03_105_jr_8012ACE0.c +++ b/src/ov_SC03_105/ov_SC03_105_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_105/ov_SC03_105_jr_80135D20.c b/src/ov_SC03_105/ov_SC03_105_jr_80135D20.c index 72a7d42434..d9e97aa36c 100644 --- a/src/ov_SC03_105/ov_SC03_105_jr_80135D20.c +++ b/src/ov_SC03_105/ov_SC03_105_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_105/ov_SC03_105_jr_801380E0.c b/src/ov_SC03_105/ov_SC03_105_jr_801380E0.c index 6af1e8e5b8..86a9d949f3 100644 --- a/src/ov_SC03_105/ov_SC03_105_jr_801380E0.c +++ b/src/ov_SC03_105/ov_SC03_105_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 76b3e359e7..6fedca428c 100644 --- a/src/ov_SC03_105/ov_SC03_105_jr_8015AE2C.c +++ b/src/ov_SC03_105/ov_SC03_105_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_105/ov_SC03_105_jr_8015C32C.c b/src/ov_SC03_105/ov_SC03_105_jr_8015C32C.c index 18dcfc5345..7cc016e554 100644 --- a/src/ov_SC03_105/ov_SC03_105_jr_8015C32C.c +++ b/src/ov_SC03_105/ov_SC03_105_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_105/ov_SC03_105_jr_8016AB6C.c b/src/ov_SC03_105/ov_SC03_105_jr_8016AB6C.c index a91250aa7b..0fa83e5c6d 100644 --- a/src/ov_SC03_105/ov_SC03_105_jr_8016AB6C.c +++ b/src/ov_SC03_105/ov_SC03_105_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_105/ov_SC03_105_jr_80171B4C.c b/src/ov_SC03_105/ov_SC03_105_jr_80171B4C.c index d07eab4812..720d971119 100644 --- a/src/ov_SC03_105/ov_SC03_105_jr_80171B4C.c +++ b/src/ov_SC03_105/ov_SC03_105_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_105/ov_SC03_105_jr_801734BC.c b/src/ov_SC03_105/ov_SC03_105_jr_801734BC.c index 5a66432008..768bf3bca5 100644 --- a/src/ov_SC03_105/ov_SC03_105_jr_801734BC.c +++ b/src/ov_SC03_105/ov_SC03_105_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_105/ov_SC03_105_o0c.c b/src/ov_SC03_105/ov_SC03_105_o0c.c index 5860900c77..612dc5e75d 100644 --- a/src/ov_SC03_105/ov_SC03_105_o0c.c +++ b/src/ov_SC03_105/ov_SC03_105_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_107/ov_SC03_107.c b/src/ov_SC03_107/ov_SC03_107.c index edfc148b23..5323769b6e 100644 --- a/src/ov_SC03_107/ov_SC03_107.c +++ b/src/ov_SC03_107/ov_SC03_107.c @@ -730,14 +730,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129cf8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129ff4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012a048 (src/shared) */ @@ -769,40 +762,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012a110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012a2f4 (src/shared) */ @@ -1111,45 +1071,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012b70c (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012b744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr. Two 16-bit BITFIELDS in a u32 container give the - * SImode, align-4 struct gcc keeps in a register. (family exemplar: src/ov_SC06_008 jr_8012ACE0) */ - - - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012b864 (src/shared) */ @@ -1896,23 +1818,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012ef70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ DEFINE_func_8012F038() /* dedup: shared engine-core @0x8012f038 (src/shared) */ @@ -1945,29 +1851,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012f374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012f49c (src/shared) */ diff --git a/src/ov_SC03_107/ov_SC03_107_jr_80131340.c b/src/ov_SC03_107/ov_SC03_107_jr_80131340.c index 83d8f15cdf..36e4889faf 100644 --- a/src/ov_SC03_107/ov_SC03_107_jr_80131340.c +++ b/src/ov_SC03_107/ov_SC03_107_jr_80131340.c @@ -870,25 +870,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319e0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131ac8 (src/shared) */ @@ -999,15 +981,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ typedef struct { s8 c[8]; } Blk8_80131CF4; @@ -1040,37 +1014,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131d68 (src/shared) */ @@ -1570,35 +1514,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339c (src/shared) */ diff --git a/src/ov_SC03_107/ov_SC03_107_jr_80135EB0.c b/src/ov_SC03_107/ov_SC03_107_jr_80135EB0.c index e25bd9a2bd..dffe52c87a 100644 --- a/src/ov_SC03_107/ov_SC03_107_jr_80135EB0.c +++ b/src/ov_SC03_107/ov_SC03_107_jr_80135EB0.c @@ -1233,17 +1233,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767c (src/shared) */ @@ -1289,32 +1279,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377b4 (src/shared) */ diff --git a/src/ov_SC03_107/ov_SC03_107_jr_801380E0.c b/src/ov_SC03_107/ov_SC03_107_jr_801380E0.c index 4cf3f0b02c..f450992927 100644 --- a/src/ov_SC03_107/ov_SC03_107_jr_801380E0.c +++ b/src/ov_SC03_107/ov_SC03_107_jr_801380E0.c @@ -1126,43 +1126,7 @@ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138db8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ed0 (src/shared) */ diff --git a/src/ov_SC03_107/ov_SC03_107_jr_8013F350.c b/src/ov_SC03_107/ov_SC03_107_jr_8013F350.c index 8c0ec1fa22..c7036fb8ef 100644 --- a/src/ov_SC03_107/ov_SC03_107_jr_8013F350.c +++ b/src/ov_SC03_107/ov_SC03_107_jr_8013F350.c @@ -4424,52 +4424,7 @@ void func_80149584(s32 param_1, s32 param_2, s32 param_3) } -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ DEFINE_func_8014964C() /* dedup: shared engine-core @0x8014964c (src/shared) */ @@ -4691,50 +4646,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014a71c (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014a830 (src/shared) */ @@ -4976,38 +4888,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014c43c (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U *)(a0 + 0x7C) = *(V4U *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ DEFINE_func_8014C568() /* dedup: shared engine-core @0x8014c568 (src/shared) */ @@ -5239,38 +5120,7 @@ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014d4c0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -5794,41 +5644,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_107/ov_SC03_107_jr_8015A3C8.c b/src/ov_SC03_107/ov_SC03_107_jr_8015A3C8.c index 5c264eedd3..d0389ac605 100644 --- a/src/ov_SC03_107/ov_SC03_107_jr_8015A3C8.c +++ b/src/ov_SC03_107/ov_SC03_107_jr_8015A3C8.c @@ -3103,20 +3103,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015c08c (src/shared) */ @@ -5407,31 +5394,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -5464,61 +5427,7 @@ DEFINE_func_80161774() /* dedup: shared engine-core @0x80161774 (src/shared) */ DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); -extern s32 func_8016163C(s32 a0, u32 a1); -extern s32 func_80161774(int a0, u32 a1); -extern s32 func_80161888(s32 a0, u32 a1); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197c (src/shared) */ @@ -6236,51 +6145,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ diff --git a/src/ov_SC03_107/ov_SC03_107_jr_8016AE5C.c b/src/ov_SC03_107/ov_SC03_107_jr_8016AE5C.c index 3ea228fd50..6527632dbc 100644 --- a/src/ov_SC03_107/ov_SC03_107_jr_8016AE5C.c +++ b/src/ov_SC03_107/ov_SC03_107_jr_8016AE5C.c @@ -3354,21 +3354,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016bf34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -4664,37 +4650,7 @@ void func_8016F0AC(void) { * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016f14c (src/shared) */ @@ -5164,26 +5120,7 @@ DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084c (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -5250,38 +5187,7 @@ DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170cb0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_107/ov_SC03_107_jr_80171B4C.c b/src/ov_SC03_107/ov_SC03_107_jr_80171B4C.c index 04e463499c..298de57532 100644 --- a/src/ov_SC03_107/ov_SC03_107_jr_80171B4C.c +++ b/src/ov_SC03_107/ov_SC03_107_jr_80171B4C.c @@ -3417,14 +3417,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172bc8 (src/shared) */ void func_80172C48(void) { } -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -3551,18 +3544,7 @@ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733cc (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ @@ -3665,41 +3647,7 @@ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173a28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) -{ - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -3880,49 +3828,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749a8 (src/shared) */ // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - - extern u16 D_80126B5E; - extern u16 D_80126B62; - extern u16 D_80126B66; - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174b6c (src/shared) */ @@ -4132,53 +4038,7 @@ DEFINE_func_801757A0() /* dedup: shared engine-core @0x801757a0 (src/shared) */ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757e0 (src/shared) */ -extern s32 func_801758FC(void); - -/* func_80175820 — twin of the byte-matched func_801759D8 / func_801758FC in this same TU - * (ov_SC01_077_jr_801734BC). Same three-part body, different slot: - * part 1 tag word = ptr[2] (0x8 vs 0x4 / 0xC) - * part 2 head ptr = D_8011F7A8+0x18 (== D_8011F7C0) - * part 3 tail ptr = D_8011F7A8+0x20 (== D_8011F7C8) - * The two __asm__ memory fences are what keep the three parts from CSE-ing their - * base addresses together (parts 1/2 stay absolute lui/%lo + idx*4; part 3 keeps the - * shared `la $v1,D_8011F7A8` + 0x18/0x20 displacements). - */ - - /* size 0x14 */ - /* size 0x0C */ - -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820 D_800AE7BC[]; - extern S_AF634_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758fc (src/shared) */ @@ -4190,44 +4050,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758fc (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -5000,41 +4823,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777bc (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_108/ov_SC03_108.c b/src/ov_SC03_108/ov_SC03_108.c index 3b374f7c5d..9266dc1323 100644 --- a/src/ov_SC03_108/ov_SC03_108.c +++ b/src/ov_SC03_108/ov_SC03_108.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_108/ov_SC03_108_after.c b/src/ov_SC03_108/ov_SC03_108_after.c index c5215bdbde..66092b606d 100644 --- a/src/ov_SC03_108/ov_SC03_108_after.c +++ b/src/ov_SC03_108/ov_SC03_108_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_108/ov_SC03_108_jr_8012ACE0.c b/src/ov_SC03_108/ov_SC03_108_jr_8012ACE0.c index c2bceea884..b627b26360 100644 --- a/src/ov_SC03_108/ov_SC03_108_jr_8012ACE0.c +++ b/src/ov_SC03_108/ov_SC03_108_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_108/ov_SC03_108_jr_80135D20.c b/src/ov_SC03_108/ov_SC03_108_jr_80135D20.c index 687cee61bb..27b7b3f289 100644 --- a/src/ov_SC03_108/ov_SC03_108_jr_80135D20.c +++ b/src/ov_SC03_108/ov_SC03_108_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_108/ov_SC03_108_jr_801380E0.c b/src/ov_SC03_108/ov_SC03_108_jr_801380E0.c index 4b4bc5fa75..aef8320703 100644 --- a/src/ov_SC03_108/ov_SC03_108_jr_801380E0.c +++ b/src/ov_SC03_108/ov_SC03_108_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 70e8994056..522c98c4bc 100644 --- a/src/ov_SC03_108/ov_SC03_108_jr_8015AE2C.c +++ b/src/ov_SC03_108/ov_SC03_108_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_108/ov_SC03_108_jr_8015C32C.c b/src/ov_SC03_108/ov_SC03_108_jr_8015C32C.c index e4239703ba..ed3314a1e7 100644 --- a/src/ov_SC03_108/ov_SC03_108_jr_8015C32C.c +++ b/src/ov_SC03_108/ov_SC03_108_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_108/ov_SC03_108_jr_8016AB6C.c b/src/ov_SC03_108/ov_SC03_108_jr_8016AB6C.c index b973224e1d..1abb1d6d34 100644 --- a/src/ov_SC03_108/ov_SC03_108_jr_8016AB6C.c +++ b/src/ov_SC03_108/ov_SC03_108_jr_8016AB6C.c @@ -2505,21 +2505,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3842,37 +3828,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4237,26 +4193,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4308,38 +4245,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_108/ov_SC03_108_jr_80171B4C.c b/src/ov_SC03_108/ov_SC03_108_jr_80171B4C.c index 8ee8fde8a5..ba56da59af 100644 --- a/src/ov_SC03_108/ov_SC03_108_jr_80171B4C.c +++ b/src/ov_SC03_108/ov_SC03_108_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_108/ov_SC03_108_jr_801734BC.c b/src/ov_SC03_108/ov_SC03_108_jr_801734BC.c index b0d9fa9d0e..cf072647dc 100644 --- a/src/ov_SC03_108/ov_SC03_108_jr_801734BC.c +++ b/src/ov_SC03_108/ov_SC03_108_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_108/ov_SC03_108_o0c.c b/src/ov_SC03_108/ov_SC03_108_o0c.c index e6dd8b5b7b..c62ebc543b 100644 --- a/src/ov_SC03_108/ov_SC03_108_o0c.c +++ b/src/ov_SC03_108/ov_SC03_108_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_109/ov_SC03_109.c b/src/ov_SC03_109/ov_SC03_109.c index 60a6728a99..87958bfdc6 100644 --- a/src/ov_SC03_109/ov_SC03_109.c +++ b/src/ov_SC03_109/ov_SC03_109.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_109/ov_SC03_109_after.c b/src/ov_SC03_109/ov_SC03_109_after.c index 25eb95d839..d4499ab2ff 100644 --- a/src/ov_SC03_109/ov_SC03_109_after.c +++ b/src/ov_SC03_109/ov_SC03_109_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_109/ov_SC03_109_jr_8012ACE0.c b/src/ov_SC03_109/ov_SC03_109_jr_8012ACE0.c index 89c2e26745..07370dbf7d 100644 --- a/src/ov_SC03_109/ov_SC03_109_jr_8012ACE0.c +++ b/src/ov_SC03_109/ov_SC03_109_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_109/ov_SC03_109_jr_80135D20.c b/src/ov_SC03_109/ov_SC03_109_jr_80135D20.c index 07f808c12d..1ae4daa712 100644 --- a/src/ov_SC03_109/ov_SC03_109_jr_80135D20.c +++ b/src/ov_SC03_109/ov_SC03_109_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_109/ov_SC03_109_jr_801380E0.c b/src/ov_SC03_109/ov_SC03_109_jr_801380E0.c index 22eeda643e..f3fb4e5c93 100644 --- a/src/ov_SC03_109/ov_SC03_109_jr_801380E0.c +++ b/src/ov_SC03_109/ov_SC03_109_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 b782e32f63..1cc1ba94db 100644 --- a/src/ov_SC03_109/ov_SC03_109_jr_8015AE2C.c +++ b/src/ov_SC03_109/ov_SC03_109_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_109/ov_SC03_109_jr_8015C32C.c b/src/ov_SC03_109/ov_SC03_109_jr_8015C32C.c index 4684768448..6562da23ec 100644 --- a/src/ov_SC03_109/ov_SC03_109_jr_8015C32C.c +++ b/src/ov_SC03_109/ov_SC03_109_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_109/ov_SC03_109_jr_8016AB6C.c b/src/ov_SC03_109/ov_SC03_109_jr_8016AB6C.c index f5d5369eb0..f638cdb538 100644 --- a/src/ov_SC03_109/ov_SC03_109_jr_8016AB6C.c +++ b/src/ov_SC03_109/ov_SC03_109_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_109/ov_SC03_109_jr_80171B4C.c b/src/ov_SC03_109/ov_SC03_109_jr_80171B4C.c index 4d5eb59723..b0829005db 100644 --- a/src/ov_SC03_109/ov_SC03_109_jr_80171B4C.c +++ b/src/ov_SC03_109/ov_SC03_109_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_109/ov_SC03_109_jr_801734BC.c b/src/ov_SC03_109/ov_SC03_109_jr_801734BC.c index cf3f33af67..a48612bc56 100644 --- a/src/ov_SC03_109/ov_SC03_109_jr_801734BC.c +++ b/src/ov_SC03_109/ov_SC03_109_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_109/ov_SC03_109_o0c.c b/src/ov_SC03_109/ov_SC03_109_o0c.c index 5e4fd6c811..b132ded17e 100644 --- a/src/ov_SC03_109/ov_SC03_109_o0c.c +++ b/src/ov_SC03_109/ov_SC03_109_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_110/ov_SC03_110.c b/src/ov_SC03_110/ov_SC03_110.c index c7bf563ab7..fb3e615c52 100644 --- a/src/ov_SC03_110/ov_SC03_110.c +++ b/src/ov_SC03_110/ov_SC03_110.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_110/ov_SC03_110_after.c b/src/ov_SC03_110/ov_SC03_110_after.c index 0baa22f647..e095540333 100644 --- a/src/ov_SC03_110/ov_SC03_110_after.c +++ b/src/ov_SC03_110/ov_SC03_110_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_110/ov_SC03_110_jr_8012ACE0.c b/src/ov_SC03_110/ov_SC03_110_jr_8012ACE0.c index 3a42fd89e1..53e9e35e5a 100644 --- a/src/ov_SC03_110/ov_SC03_110_jr_8012ACE0.c +++ b/src/ov_SC03_110/ov_SC03_110_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_110/ov_SC03_110_jr_80135D20.c b/src/ov_SC03_110/ov_SC03_110_jr_80135D20.c index 1a51342590..8660156891 100644 --- a/src/ov_SC03_110/ov_SC03_110_jr_80135D20.c +++ b/src/ov_SC03_110/ov_SC03_110_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_110/ov_SC03_110_jr_801380E0.c b/src/ov_SC03_110/ov_SC03_110_jr_801380E0.c index 6dac59d07f..a6495946fa 100644 --- a/src/ov_SC03_110/ov_SC03_110_jr_801380E0.c +++ b/src/ov_SC03_110/ov_SC03_110_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 1105a89210..24e0a95e6b 100644 --- a/src/ov_SC03_110/ov_SC03_110_jr_8015AE2C.c +++ b/src/ov_SC03_110/ov_SC03_110_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_110/ov_SC03_110_jr_8015C32C.c b/src/ov_SC03_110/ov_SC03_110_jr_8015C32C.c index 61adf156f1..66a50c545f 100644 --- a/src/ov_SC03_110/ov_SC03_110_jr_8015C32C.c +++ b/src/ov_SC03_110/ov_SC03_110_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_110/ov_SC03_110_jr_8016AB6C.c b/src/ov_SC03_110/ov_SC03_110_jr_8016AB6C.c index e3ffe97068..2cdf11a6df 100644 --- a/src/ov_SC03_110/ov_SC03_110_jr_8016AB6C.c +++ b/src/ov_SC03_110/ov_SC03_110_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_110/ov_SC03_110_jr_80171B4C.c b/src/ov_SC03_110/ov_SC03_110_jr_80171B4C.c index def25fd06f..391ac46c8d 100644 --- a/src/ov_SC03_110/ov_SC03_110_jr_80171B4C.c +++ b/src/ov_SC03_110/ov_SC03_110_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_110/ov_SC03_110_jr_801734BC.c b/src/ov_SC03_110/ov_SC03_110_jr_801734BC.c index bcb051e93d..f09e50217d 100644 --- a/src/ov_SC03_110/ov_SC03_110_jr_801734BC.c +++ b/src/ov_SC03_110/ov_SC03_110_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_110/ov_SC03_110_o0c.c b/src/ov_SC03_110/ov_SC03_110_o0c.c index f648e1fa2f..d259235bdf 100644 --- a/src/ov_SC03_110/ov_SC03_110_o0c.c +++ b/src/ov_SC03_110/ov_SC03_110_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_111/ov_SC03_111.c b/src/ov_SC03_111/ov_SC03_111.c index 57b6721953..57ea12a311 100644 --- a/src/ov_SC03_111/ov_SC03_111.c +++ b/src/ov_SC03_111/ov_SC03_111.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_111/ov_SC03_111_after.c b/src/ov_SC03_111/ov_SC03_111_after.c index d6748279f6..836f658e22 100644 --- a/src/ov_SC03_111/ov_SC03_111_after.c +++ b/src/ov_SC03_111/ov_SC03_111_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_111/ov_SC03_111_jr_8012ACE0.c b/src/ov_SC03_111/ov_SC03_111_jr_8012ACE0.c index d067d5af49..4b149a9619 100644 --- a/src/ov_SC03_111/ov_SC03_111_jr_8012ACE0.c +++ b/src/ov_SC03_111/ov_SC03_111_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_111/ov_SC03_111_jr_80135D20.c b/src/ov_SC03_111/ov_SC03_111_jr_80135D20.c index 71bdd2b582..397b83fa42 100644 --- a/src/ov_SC03_111/ov_SC03_111_jr_80135D20.c +++ b/src/ov_SC03_111/ov_SC03_111_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_111/ov_SC03_111_jr_801380E0.c b/src/ov_SC03_111/ov_SC03_111_jr_801380E0.c index aecc3c68e9..41037916ce 100644 --- a/src/ov_SC03_111/ov_SC03_111_jr_801380E0.c +++ b/src/ov_SC03_111/ov_SC03_111_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 4470c5d88a..2829edf97b 100644 --- a/src/ov_SC03_111/ov_SC03_111_jr_8015AE2C.c +++ b/src/ov_SC03_111/ov_SC03_111_jr_8015AE2C.c @@ -1816,20 +1816,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_111/ov_SC03_111_jr_8015C32C.c b/src/ov_SC03_111/ov_SC03_111_jr_8015C32C.c index f32d70a36e..22b3f43114 100644 --- a/src/ov_SC03_111/ov_SC03_111_jr_8015C32C.c +++ b/src/ov_SC03_111/ov_SC03_111_jr_8015C32C.c @@ -3354,31 +3354,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3503,58 +3479,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4190,21 +4115,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4280,51 +4191,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_111/ov_SC03_111_jr_8016AB6C.c b/src/ov_SC03_111/ov_SC03_111_jr_8016AB6C.c index 4317f2594f..8ee5b92835 100644 --- a/src/ov_SC03_111/ov_SC03_111_jr_8016AB6C.c +++ b/src/ov_SC03_111/ov_SC03_111_jr_8016AB6C.c @@ -2555,21 +2555,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3892,37 +3878,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4287,26 +4243,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4358,38 +4295,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_111/ov_SC03_111_jr_80171B4C.c b/src/ov_SC03_111/ov_SC03_111_jr_80171B4C.c index b399e9aa93..95e6a52837 100644 --- a/src/ov_SC03_111/ov_SC03_111_jr_80171B4C.c +++ b/src/ov_SC03_111/ov_SC03_111_jr_80171B4C.c @@ -2423,14 +2423,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2547,18 +2540,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_111/ov_SC03_111_jr_801734BC.c b/src/ov_SC03_111/ov_SC03_111_jr_801734BC.c index dc521a9e04..bca8a491f6 100644 --- a/src/ov_SC03_111/ov_SC03_111_jr_801734BC.c +++ b/src/ov_SC03_111/ov_SC03_111_jr_801734BC.c @@ -2413,40 +2413,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2620,49 +2587,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2862,38 +2787,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2903,44 +2797,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3731,41 +3588,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_111/ov_SC03_111_o0c.c b/src/ov_SC03_111/ov_SC03_111_o0c.c index 702f3561ff..74f38ee75a 100644 --- a/src/ov_SC03_111/ov_SC03_111_o0c.c +++ b/src/ov_SC03_111/ov_SC03_111_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_112/ov_SC03_112.c b/src/ov_SC03_112/ov_SC03_112.c index 540939ed4e..eef8f9a6f4 100644 --- a/src/ov_SC03_112/ov_SC03_112.c +++ b/src/ov_SC03_112/ov_SC03_112.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_112/ov_SC03_112_after.c b/src/ov_SC03_112/ov_SC03_112_after.c index 3c4d58fa69..f19afba594 100644 --- a/src/ov_SC03_112/ov_SC03_112_after.c +++ b/src/ov_SC03_112/ov_SC03_112_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_112/ov_SC03_112_jr_8012ACE0.c b/src/ov_SC03_112/ov_SC03_112_jr_8012ACE0.c index e0b7d9802d..0dbcd3029b 100644 --- a/src/ov_SC03_112/ov_SC03_112_jr_8012ACE0.c +++ b/src/ov_SC03_112/ov_SC03_112_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_112/ov_SC03_112_jr_80135D20.c b/src/ov_SC03_112/ov_SC03_112_jr_80135D20.c index b88b42322a..bb6d47eba0 100644 --- a/src/ov_SC03_112/ov_SC03_112_jr_80135D20.c +++ b/src/ov_SC03_112/ov_SC03_112_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_112/ov_SC03_112_jr_801380E0.c b/src/ov_SC03_112/ov_SC03_112_jr_801380E0.c index 1aed25234d..a02500d41c 100644 --- a/src/ov_SC03_112/ov_SC03_112_jr_801380E0.c +++ b/src/ov_SC03_112/ov_SC03_112_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 dbb3aa62e3..aedb516cca 100644 --- a/src/ov_SC03_112/ov_SC03_112_jr_8015AE2C.c +++ b/src/ov_SC03_112/ov_SC03_112_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_112/ov_SC03_112_jr_8015C32C.c b/src/ov_SC03_112/ov_SC03_112_jr_8015C32C.c index 8fc10e8554..b18b36b255 100644 --- a/src/ov_SC03_112/ov_SC03_112_jr_8015C32C.c +++ b/src/ov_SC03_112/ov_SC03_112_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_112/ov_SC03_112_jr_8016AB6C.c b/src/ov_SC03_112/ov_SC03_112_jr_8016AB6C.c index ca7d8e0b7b..96ffdbf5df 100644 --- a/src/ov_SC03_112/ov_SC03_112_jr_8016AB6C.c +++ b/src/ov_SC03_112/ov_SC03_112_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_112/ov_SC03_112_jr_80171B4C.c b/src/ov_SC03_112/ov_SC03_112_jr_80171B4C.c index b1a2156661..f9f7f1f0c4 100644 --- a/src/ov_SC03_112/ov_SC03_112_jr_80171B4C.c +++ b/src/ov_SC03_112/ov_SC03_112_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_112/ov_SC03_112_jr_801734BC.c b/src/ov_SC03_112/ov_SC03_112_jr_801734BC.c index 3a8bc22946..72b4a33385 100644 --- a/src/ov_SC03_112/ov_SC03_112_jr_801734BC.c +++ b/src/ov_SC03_112/ov_SC03_112_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_112/ov_SC03_112_o0c.c b/src/ov_SC03_112/ov_SC03_112_o0c.c index 71f0e08607..65576ac608 100644 --- a/src/ov_SC03_112/ov_SC03_112_o0c.c +++ b/src/ov_SC03_112/ov_SC03_112_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_113/ov_SC03_113.c b/src/ov_SC03_113/ov_SC03_113.c index b9c6aa8f5f..52e4498b20 100644 --- a/src/ov_SC03_113/ov_SC03_113.c +++ b/src/ov_SC03_113/ov_SC03_113.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_113/ov_SC03_113_after.c b/src/ov_SC03_113/ov_SC03_113_after.c index 01665fccbc..c89bc457b8 100644 --- a/src/ov_SC03_113/ov_SC03_113_after.c +++ b/src/ov_SC03_113/ov_SC03_113_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_113/ov_SC03_113_jr_8012ACE0.c b/src/ov_SC03_113/ov_SC03_113_jr_8012ACE0.c index 4df035a7f8..af02d64cdb 100644 --- a/src/ov_SC03_113/ov_SC03_113_jr_8012ACE0.c +++ b/src/ov_SC03_113/ov_SC03_113_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_113/ov_SC03_113_jr_80135D20.c b/src/ov_SC03_113/ov_SC03_113_jr_80135D20.c index 7e98a1292f..f2c4c021c1 100644 --- a/src/ov_SC03_113/ov_SC03_113_jr_80135D20.c +++ b/src/ov_SC03_113/ov_SC03_113_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_113/ov_SC03_113_jr_801380E0.c b/src/ov_SC03_113/ov_SC03_113_jr_801380E0.c index 5100a85407..3c3182e6a7 100644 --- a/src/ov_SC03_113/ov_SC03_113_jr_801380E0.c +++ b/src/ov_SC03_113/ov_SC03_113_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 4453a15c70..6e99cbe4af 100644 --- a/src/ov_SC03_113/ov_SC03_113_jr_8015AE2C.c +++ b/src/ov_SC03_113/ov_SC03_113_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_113/ov_SC03_113_jr_8015C32C.c b/src/ov_SC03_113/ov_SC03_113_jr_8015C32C.c index 135a969146..9b10d5efac 100644 --- a/src/ov_SC03_113/ov_SC03_113_jr_8015C32C.c +++ b/src/ov_SC03_113/ov_SC03_113_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_113/ov_SC03_113_jr_8016AB6C.c b/src/ov_SC03_113/ov_SC03_113_jr_8016AB6C.c index 5e5836cd4e..a987d3c6cd 100644 --- a/src/ov_SC03_113/ov_SC03_113_jr_8016AB6C.c +++ b/src/ov_SC03_113/ov_SC03_113_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_113/ov_SC03_113_jr_80171B4C.c b/src/ov_SC03_113/ov_SC03_113_jr_80171B4C.c index 793abb1862..07c54a6bfd 100644 --- a/src/ov_SC03_113/ov_SC03_113_jr_80171B4C.c +++ b/src/ov_SC03_113/ov_SC03_113_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_113/ov_SC03_113_jr_801734BC.c b/src/ov_SC03_113/ov_SC03_113_jr_801734BC.c index 0dee08bad7..7c0b77d83d 100644 --- a/src/ov_SC03_113/ov_SC03_113_jr_801734BC.c +++ b/src/ov_SC03_113/ov_SC03_113_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_113/ov_SC03_113_o0c.c b/src/ov_SC03_113/ov_SC03_113_o0c.c index 09df0ae7f2..18b50ee9b3 100644 --- a/src/ov_SC03_113/ov_SC03_113_o0c.c +++ b/src/ov_SC03_113/ov_SC03_113_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_114/ov_SC03_114.c b/src/ov_SC03_114/ov_SC03_114.c index a6efb9f658..b0a37b324a 100644 --- a/src/ov_SC03_114/ov_SC03_114.c +++ b/src/ov_SC03_114/ov_SC03_114.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_114/ov_SC03_114_after.c b/src/ov_SC03_114/ov_SC03_114_after.c index 33dd2b8bd2..2738967d63 100644 --- a/src/ov_SC03_114/ov_SC03_114_after.c +++ b/src/ov_SC03_114/ov_SC03_114_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_114/ov_SC03_114_jr_8012ACE0.c b/src/ov_SC03_114/ov_SC03_114_jr_8012ACE0.c index bfba620840..46b33a90a4 100644 --- a/src/ov_SC03_114/ov_SC03_114_jr_8012ACE0.c +++ b/src/ov_SC03_114/ov_SC03_114_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_114/ov_SC03_114_jr_80135D20.c b/src/ov_SC03_114/ov_SC03_114_jr_80135D20.c index f9340f876f..b56e6e76fa 100644 --- a/src/ov_SC03_114/ov_SC03_114_jr_80135D20.c +++ b/src/ov_SC03_114/ov_SC03_114_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_114/ov_SC03_114_jr_801380E0.c b/src/ov_SC03_114/ov_SC03_114_jr_801380E0.c index 6fda593cfc..8e67b5b0b5 100644 --- a/src/ov_SC03_114/ov_SC03_114_jr_801380E0.c +++ b/src/ov_SC03_114/ov_SC03_114_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 875f989cb9..c3bdce62d5 100644 --- a/src/ov_SC03_114/ov_SC03_114_jr_8015AE2C.c +++ b/src/ov_SC03_114/ov_SC03_114_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_114/ov_SC03_114_jr_8015C32C.c b/src/ov_SC03_114/ov_SC03_114_jr_8015C32C.c index 00165950aa..514a7e9fc1 100644 --- a/src/ov_SC03_114/ov_SC03_114_jr_8015C32C.c +++ b/src/ov_SC03_114/ov_SC03_114_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_114/ov_SC03_114_jr_8016AB6C.c b/src/ov_SC03_114/ov_SC03_114_jr_8016AB6C.c index a60ae17431..c6a00049aa 100644 --- a/src/ov_SC03_114/ov_SC03_114_jr_8016AB6C.c +++ b/src/ov_SC03_114/ov_SC03_114_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_114/ov_SC03_114_jr_80171B4C.c b/src/ov_SC03_114/ov_SC03_114_jr_80171B4C.c index 82e1e1e517..5de56b9b91 100644 --- a/src/ov_SC03_114/ov_SC03_114_jr_80171B4C.c +++ b/src/ov_SC03_114/ov_SC03_114_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_114/ov_SC03_114_jr_801734BC.c b/src/ov_SC03_114/ov_SC03_114_jr_801734BC.c index cb9cb9523c..cf229ee674 100644 --- a/src/ov_SC03_114/ov_SC03_114_jr_801734BC.c +++ b/src/ov_SC03_114/ov_SC03_114_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_114/ov_SC03_114_o0c.c b/src/ov_SC03_114/ov_SC03_114_o0c.c index f8e6373bb4..e8cd7f99be 100644 --- a/src/ov_SC03_114/ov_SC03_114_o0c.c +++ b/src/ov_SC03_114/ov_SC03_114_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_115/ov_SC03_115.c b/src/ov_SC03_115/ov_SC03_115.c index 8743191c6a..d14185d6f5 100644 --- a/src/ov_SC03_115/ov_SC03_115.c +++ b/src/ov_SC03_115/ov_SC03_115.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_115/ov_SC03_115_after.c b/src/ov_SC03_115/ov_SC03_115_after.c index 4b60d5654b..5c23760870 100644 --- a/src/ov_SC03_115/ov_SC03_115_after.c +++ b/src/ov_SC03_115/ov_SC03_115_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_115/ov_SC03_115_jr_8012ACE0.c b/src/ov_SC03_115/ov_SC03_115_jr_8012ACE0.c index f3cdbc1518..0631e4e0ee 100644 --- a/src/ov_SC03_115/ov_SC03_115_jr_8012ACE0.c +++ b/src/ov_SC03_115/ov_SC03_115_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_115/ov_SC03_115_jr_80135D20.c b/src/ov_SC03_115/ov_SC03_115_jr_80135D20.c index f5189c0db3..7a5f44e990 100644 --- a/src/ov_SC03_115/ov_SC03_115_jr_80135D20.c +++ b/src/ov_SC03_115/ov_SC03_115_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_115/ov_SC03_115_jr_801380E0.c b/src/ov_SC03_115/ov_SC03_115_jr_801380E0.c index e3a9cfc563..35108d60c1 100644 --- a/src/ov_SC03_115/ov_SC03_115_jr_801380E0.c +++ b/src/ov_SC03_115/ov_SC03_115_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 5c72c46192..cb8f534119 100644 --- a/src/ov_SC03_115/ov_SC03_115_jr_8015AE2C.c +++ b/src/ov_SC03_115/ov_SC03_115_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_115/ov_SC03_115_jr_8015C32C.c b/src/ov_SC03_115/ov_SC03_115_jr_8015C32C.c index 8a99f5c6e6..f6888a887d 100644 --- a/src/ov_SC03_115/ov_SC03_115_jr_8015C32C.c +++ b/src/ov_SC03_115/ov_SC03_115_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_115/ov_SC03_115_jr_8016AB6C.c b/src/ov_SC03_115/ov_SC03_115_jr_8016AB6C.c index 97719e637d..f72a9ca29f 100644 --- a/src/ov_SC03_115/ov_SC03_115_jr_8016AB6C.c +++ b/src/ov_SC03_115/ov_SC03_115_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_115/ov_SC03_115_jr_80171B4C.c b/src/ov_SC03_115/ov_SC03_115_jr_80171B4C.c index 237fb0cec2..cb7f73a2d3 100644 --- a/src/ov_SC03_115/ov_SC03_115_jr_80171B4C.c +++ b/src/ov_SC03_115/ov_SC03_115_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_115/ov_SC03_115_jr_801734BC.c b/src/ov_SC03_115/ov_SC03_115_jr_801734BC.c index 333ff2cf3b..4f9cb2bd59 100644 --- a/src/ov_SC03_115/ov_SC03_115_jr_801734BC.c +++ b/src/ov_SC03_115/ov_SC03_115_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_115/ov_SC03_115_o0c.c b/src/ov_SC03_115/ov_SC03_115_o0c.c index b17d70cfc4..9c10419dd7 100644 --- a/src/ov_SC03_115/ov_SC03_115_o0c.c +++ b/src/ov_SC03_115/ov_SC03_115_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_116/ov_SC03_116.c b/src/ov_SC03_116/ov_SC03_116.c index 9e8bc61b56..76d682749c 100644 --- a/src/ov_SC03_116/ov_SC03_116.c +++ b/src/ov_SC03_116/ov_SC03_116.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_116/ov_SC03_116_after.c b/src/ov_SC03_116/ov_SC03_116_after.c index 1aa3492c18..dec1ff26a0 100644 --- a/src/ov_SC03_116/ov_SC03_116_after.c +++ b/src/ov_SC03_116/ov_SC03_116_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_116/ov_SC03_116_jr_8012ACE0.c b/src/ov_SC03_116/ov_SC03_116_jr_8012ACE0.c index be7ad0aad0..e323e892d4 100644 --- a/src/ov_SC03_116/ov_SC03_116_jr_8012ACE0.c +++ b/src/ov_SC03_116/ov_SC03_116_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_116/ov_SC03_116_jr_80135D20.c b/src/ov_SC03_116/ov_SC03_116_jr_80135D20.c index 0627774181..57219056b3 100644 --- a/src/ov_SC03_116/ov_SC03_116_jr_80135D20.c +++ b/src/ov_SC03_116/ov_SC03_116_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_116/ov_SC03_116_jr_801380E0.c b/src/ov_SC03_116/ov_SC03_116_jr_801380E0.c index da6831b1e2..8de71caa1d 100644 --- a/src/ov_SC03_116/ov_SC03_116_jr_801380E0.c +++ b/src/ov_SC03_116/ov_SC03_116_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 953b906ee6..064cd9ccca 100644 --- a/src/ov_SC03_116/ov_SC03_116_jr_8015AE2C.c +++ b/src/ov_SC03_116/ov_SC03_116_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_116/ov_SC03_116_jr_8015C32C.c b/src/ov_SC03_116/ov_SC03_116_jr_8015C32C.c index 3a90cf9e7d..a7092b5ed0 100644 --- a/src/ov_SC03_116/ov_SC03_116_jr_8015C32C.c +++ b/src/ov_SC03_116/ov_SC03_116_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_116/ov_SC03_116_jr_8016AB6C.c b/src/ov_SC03_116/ov_SC03_116_jr_8016AB6C.c index b9818d76df..3509effbb3 100644 --- a/src/ov_SC03_116/ov_SC03_116_jr_8016AB6C.c +++ b/src/ov_SC03_116/ov_SC03_116_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_116/ov_SC03_116_jr_80171B4C.c b/src/ov_SC03_116/ov_SC03_116_jr_80171B4C.c index dde48c0ee3..5a78770c64 100644 --- a/src/ov_SC03_116/ov_SC03_116_jr_80171B4C.c +++ b/src/ov_SC03_116/ov_SC03_116_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_116/ov_SC03_116_jr_801734BC.c b/src/ov_SC03_116/ov_SC03_116_jr_801734BC.c index 94d48db420..5fbdad8abe 100644 --- a/src/ov_SC03_116/ov_SC03_116_jr_801734BC.c +++ b/src/ov_SC03_116/ov_SC03_116_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_116/ov_SC03_116_o0c.c b/src/ov_SC03_116/ov_SC03_116_o0c.c index 014e8930ee..c39fabe0d1 100644 --- a/src/ov_SC03_116/ov_SC03_116_o0c.c +++ b/src/ov_SC03_116/ov_SC03_116_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_117/ov_SC03_117.c b/src/ov_SC03_117/ov_SC03_117.c index 8917276388..340ea4bab4 100644 --- a/src/ov_SC03_117/ov_SC03_117.c +++ b/src/ov_SC03_117/ov_SC03_117.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_117/ov_SC03_117_after.c b/src/ov_SC03_117/ov_SC03_117_after.c index 1950fd778e..6690a5bf91 100644 --- a/src/ov_SC03_117/ov_SC03_117_after.c +++ b/src/ov_SC03_117/ov_SC03_117_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_117/ov_SC03_117_jr_8012ACE0.c b/src/ov_SC03_117/ov_SC03_117_jr_8012ACE0.c index 39e289d71e..3128de50e0 100644 --- a/src/ov_SC03_117/ov_SC03_117_jr_8012ACE0.c +++ b/src/ov_SC03_117/ov_SC03_117_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_117/ov_SC03_117_jr_80135D20.c b/src/ov_SC03_117/ov_SC03_117_jr_80135D20.c index c3e5f35e74..fc9ff4c8c7 100644 --- a/src/ov_SC03_117/ov_SC03_117_jr_80135D20.c +++ b/src/ov_SC03_117/ov_SC03_117_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_117/ov_SC03_117_jr_801380E0.c b/src/ov_SC03_117/ov_SC03_117_jr_801380E0.c index f87fc7b145..79929c3270 100644 --- a/src/ov_SC03_117/ov_SC03_117_jr_801380E0.c +++ b/src/ov_SC03_117/ov_SC03_117_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 43e79d8250..aad3e5154e 100644 --- a/src/ov_SC03_117/ov_SC03_117_jr_8015AE2C.c +++ b/src/ov_SC03_117/ov_SC03_117_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_117/ov_SC03_117_jr_8015C32C.c b/src/ov_SC03_117/ov_SC03_117_jr_8015C32C.c index a4ffc4402d..fcfe5aeb5d 100644 --- a/src/ov_SC03_117/ov_SC03_117_jr_8015C32C.c +++ b/src/ov_SC03_117/ov_SC03_117_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_117/ov_SC03_117_jr_8016AB6C.c b/src/ov_SC03_117/ov_SC03_117_jr_8016AB6C.c index e68f2c70ff..12e4838bfc 100644 --- a/src/ov_SC03_117/ov_SC03_117_jr_8016AB6C.c +++ b/src/ov_SC03_117/ov_SC03_117_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_117/ov_SC03_117_jr_80171B4C.c b/src/ov_SC03_117/ov_SC03_117_jr_80171B4C.c index cf25b7e89e..cb592f364c 100644 --- a/src/ov_SC03_117/ov_SC03_117_jr_80171B4C.c +++ b/src/ov_SC03_117/ov_SC03_117_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_117/ov_SC03_117_jr_801734BC.c b/src/ov_SC03_117/ov_SC03_117_jr_801734BC.c index bc0b84d433..25691435dc 100644 --- a/src/ov_SC03_117/ov_SC03_117_jr_801734BC.c +++ b/src/ov_SC03_117/ov_SC03_117_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_117/ov_SC03_117_o0c.c b/src/ov_SC03_117/ov_SC03_117_o0c.c index 89198df0a8..14b92d3729 100644 --- a/src/ov_SC03_117/ov_SC03_117_o0c.c +++ b/src/ov_SC03_117/ov_SC03_117_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_118/ov_SC03_118.c b/src/ov_SC03_118/ov_SC03_118.c index 945f353012..030ff5a410 100644 --- a/src/ov_SC03_118/ov_SC03_118.c +++ b/src/ov_SC03_118/ov_SC03_118.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_118/ov_SC03_118_after.c b/src/ov_SC03_118/ov_SC03_118_after.c index e5d8919775..756e9495f7 100644 --- a/src/ov_SC03_118/ov_SC03_118_after.c +++ b/src/ov_SC03_118/ov_SC03_118_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_118/ov_SC03_118_jr_8012ACE0.c b/src/ov_SC03_118/ov_SC03_118_jr_8012ACE0.c index 11ece81452..77c1368872 100644 --- a/src/ov_SC03_118/ov_SC03_118_jr_8012ACE0.c +++ b/src/ov_SC03_118/ov_SC03_118_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_118/ov_SC03_118_jr_80135D20.c b/src/ov_SC03_118/ov_SC03_118_jr_80135D20.c index 2b5423e19b..1f7122343f 100644 --- a/src/ov_SC03_118/ov_SC03_118_jr_80135D20.c +++ b/src/ov_SC03_118/ov_SC03_118_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_118/ov_SC03_118_jr_801380E0.c b/src/ov_SC03_118/ov_SC03_118_jr_801380E0.c index 66e7b0d954..ddf5012da8 100644 --- a/src/ov_SC03_118/ov_SC03_118_jr_801380E0.c +++ b/src/ov_SC03_118/ov_SC03_118_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 637e9c136e..2e728eb675 100644 --- a/src/ov_SC03_118/ov_SC03_118_jr_8015AE2C.c +++ b/src/ov_SC03_118/ov_SC03_118_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_118/ov_SC03_118_jr_8015C32C.c b/src/ov_SC03_118/ov_SC03_118_jr_8015C32C.c index cb794fe305..430a408c61 100644 --- a/src/ov_SC03_118/ov_SC03_118_jr_8015C32C.c +++ b/src/ov_SC03_118/ov_SC03_118_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_118/ov_SC03_118_jr_8016AB6C.c b/src/ov_SC03_118/ov_SC03_118_jr_8016AB6C.c index d78a2ec46e..4f45651bda 100644 --- a/src/ov_SC03_118/ov_SC03_118_jr_8016AB6C.c +++ b/src/ov_SC03_118/ov_SC03_118_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_118/ov_SC03_118_jr_80171B4C.c b/src/ov_SC03_118/ov_SC03_118_jr_80171B4C.c index 2cc23efc32..72d8c064f9 100644 --- a/src/ov_SC03_118/ov_SC03_118_jr_80171B4C.c +++ b/src/ov_SC03_118/ov_SC03_118_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_118/ov_SC03_118_jr_801734BC.c b/src/ov_SC03_118/ov_SC03_118_jr_801734BC.c index 5a999ba608..242fcc0a21 100644 --- a/src/ov_SC03_118/ov_SC03_118_jr_801734BC.c +++ b/src/ov_SC03_118/ov_SC03_118_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_118/ov_SC03_118_o0c.c b/src/ov_SC03_118/ov_SC03_118_o0c.c index fcf30f6969..07d808671e 100644 --- a/src/ov_SC03_118/ov_SC03_118_o0c.c +++ b/src/ov_SC03_118/ov_SC03_118_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_119/ov_SC03_119.c b/src/ov_SC03_119/ov_SC03_119.c index 945f353012..030ff5a410 100644 --- a/src/ov_SC03_119/ov_SC03_119.c +++ b/src/ov_SC03_119/ov_SC03_119.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_119/ov_SC03_119_after.c b/src/ov_SC03_119/ov_SC03_119_after.c index e82c82c5fb..87410c3b8c 100644 --- a/src/ov_SC03_119/ov_SC03_119_after.c +++ b/src/ov_SC03_119/ov_SC03_119_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_119/ov_SC03_119_jr_8012ACE0.c b/src/ov_SC03_119/ov_SC03_119_jr_8012ACE0.c index 11ece81452..77c1368872 100644 --- a/src/ov_SC03_119/ov_SC03_119_jr_8012ACE0.c +++ b/src/ov_SC03_119/ov_SC03_119_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_119/ov_SC03_119_jr_80135D20.c b/src/ov_SC03_119/ov_SC03_119_jr_80135D20.c index 2b5423e19b..1f7122343f 100644 --- a/src/ov_SC03_119/ov_SC03_119_jr_80135D20.c +++ b/src/ov_SC03_119/ov_SC03_119_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_119/ov_SC03_119_jr_801380E0.c b/src/ov_SC03_119/ov_SC03_119_jr_801380E0.c index 66e7b0d954..ddf5012da8 100644 --- a/src/ov_SC03_119/ov_SC03_119_jr_801380E0.c +++ b/src/ov_SC03_119/ov_SC03_119_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 637e9c136e..2e728eb675 100644 --- a/src/ov_SC03_119/ov_SC03_119_jr_8015AE2C.c +++ b/src/ov_SC03_119/ov_SC03_119_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_119/ov_SC03_119_jr_8015C32C.c b/src/ov_SC03_119/ov_SC03_119_jr_8015C32C.c index cb794fe305..430a408c61 100644 --- a/src/ov_SC03_119/ov_SC03_119_jr_8015C32C.c +++ b/src/ov_SC03_119/ov_SC03_119_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_119/ov_SC03_119_jr_8016AB6C.c b/src/ov_SC03_119/ov_SC03_119_jr_8016AB6C.c index d78a2ec46e..4f45651bda 100644 --- a/src/ov_SC03_119/ov_SC03_119_jr_8016AB6C.c +++ b/src/ov_SC03_119/ov_SC03_119_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_119/ov_SC03_119_jr_80171B4C.c b/src/ov_SC03_119/ov_SC03_119_jr_80171B4C.c index 2cc23efc32..72d8c064f9 100644 --- a/src/ov_SC03_119/ov_SC03_119_jr_80171B4C.c +++ b/src/ov_SC03_119/ov_SC03_119_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_119/ov_SC03_119_jr_801734BC.c b/src/ov_SC03_119/ov_SC03_119_jr_801734BC.c index 5a999ba608..242fcc0a21 100644 --- a/src/ov_SC03_119/ov_SC03_119_jr_801734BC.c +++ b/src/ov_SC03_119/ov_SC03_119_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_119/ov_SC03_119_o0c.c b/src/ov_SC03_119/ov_SC03_119_o0c.c index fcf30f6969..07d808671e 100644 --- a/src/ov_SC03_119/ov_SC03_119_o0c.c +++ b/src/ov_SC03_119/ov_SC03_119_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_121/ov_SC03_121.c b/src/ov_SC03_121/ov_SC03_121.c index 8dc0ef6683..e3fdd404b7 100644 --- a/src/ov_SC03_121/ov_SC03_121.c +++ b/src/ov_SC03_121/ov_SC03_121.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_121/ov_SC03_121_after.c b/src/ov_SC03_121/ov_SC03_121_after.c index ffc0147176..0e680d1b2b 100644 --- a/src/ov_SC03_121/ov_SC03_121_after.c +++ b/src/ov_SC03_121/ov_SC03_121_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_121/ov_SC03_121_jr_8012ACE0.c b/src/ov_SC03_121/ov_SC03_121_jr_8012ACE0.c index 5fe8fce815..89746eee27 100644 --- a/src/ov_SC03_121/ov_SC03_121_jr_8012ACE0.c +++ b/src/ov_SC03_121/ov_SC03_121_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_121/ov_SC03_121_jr_80135D20.c b/src/ov_SC03_121/ov_SC03_121_jr_80135D20.c index 327f68bcd2..43deb449fa 100644 --- a/src/ov_SC03_121/ov_SC03_121_jr_80135D20.c +++ b/src/ov_SC03_121/ov_SC03_121_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_121/ov_SC03_121_jr_801380E0.c b/src/ov_SC03_121/ov_SC03_121_jr_801380E0.c index f729af3768..d5de403cda 100644 --- a/src/ov_SC03_121/ov_SC03_121_jr_801380E0.c +++ b/src/ov_SC03_121/ov_SC03_121_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 0b28a3a15e..0f8ef72c72 100644 --- a/src/ov_SC03_121/ov_SC03_121_jr_8015AE2C.c +++ b/src/ov_SC03_121/ov_SC03_121_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_121/ov_SC03_121_jr_8015C32C.c b/src/ov_SC03_121/ov_SC03_121_jr_8015C32C.c index d216a05dc1..6a440df615 100644 --- a/src/ov_SC03_121/ov_SC03_121_jr_8015C32C.c +++ b/src/ov_SC03_121/ov_SC03_121_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_121/ov_SC03_121_jr_8016AB6C.c b/src/ov_SC03_121/ov_SC03_121_jr_8016AB6C.c index 4069c71187..9901e04329 100644 --- a/src/ov_SC03_121/ov_SC03_121_jr_8016AB6C.c +++ b/src/ov_SC03_121/ov_SC03_121_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_121/ov_SC03_121_jr_80171B4C.c b/src/ov_SC03_121/ov_SC03_121_jr_80171B4C.c index b4ae9f4ce8..08ee9756f7 100644 --- a/src/ov_SC03_121/ov_SC03_121_jr_80171B4C.c +++ b/src/ov_SC03_121/ov_SC03_121_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_121/ov_SC03_121_jr_801734BC.c b/src/ov_SC03_121/ov_SC03_121_jr_801734BC.c index ca334642fe..3a0f4af537 100644 --- a/src/ov_SC03_121/ov_SC03_121_jr_801734BC.c +++ b/src/ov_SC03_121/ov_SC03_121_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_121/ov_SC03_121_o0c.c b/src/ov_SC03_121/ov_SC03_121_o0c.c index 3a2336b322..323e3e9955 100644 --- a/src/ov_SC03_121/ov_SC03_121_o0c.c +++ b/src/ov_SC03_121/ov_SC03_121_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_124/ov_SC03_124.c b/src/ov_SC03_124/ov_SC03_124.c index 4d694838f9..cb32f5b4d5 100644 --- a/src/ov_SC03_124/ov_SC03_124.c +++ b/src/ov_SC03_124/ov_SC03_124.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_124/ov_SC03_124_after.c b/src/ov_SC03_124/ov_SC03_124_after.c index bd927dedc4..e1cf7f3a49 100644 --- a/src/ov_SC03_124/ov_SC03_124_after.c +++ b/src/ov_SC03_124/ov_SC03_124_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_124/ov_SC03_124_jr_8012ACE0.c b/src/ov_SC03_124/ov_SC03_124_jr_8012ACE0.c index 72b541ebcb..a79756b931 100644 --- a/src/ov_SC03_124/ov_SC03_124_jr_8012ACE0.c +++ b/src/ov_SC03_124/ov_SC03_124_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_124/ov_SC03_124_jr_80135D20.c b/src/ov_SC03_124/ov_SC03_124_jr_80135D20.c index 410b61c02f..81e7d833e9 100644 --- a/src/ov_SC03_124/ov_SC03_124_jr_80135D20.c +++ b/src/ov_SC03_124/ov_SC03_124_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_124/ov_SC03_124_jr_801380E0.c b/src/ov_SC03_124/ov_SC03_124_jr_801380E0.c index 4115e3d10d..c7796697e6 100644 --- a/src/ov_SC03_124/ov_SC03_124_jr_801380E0.c +++ b/src/ov_SC03_124/ov_SC03_124_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 f2b348a77c..9a8cdd3ea0 100644 --- a/src/ov_SC03_124/ov_SC03_124_jr_8015AE2C.c +++ b/src/ov_SC03_124/ov_SC03_124_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_124/ov_SC03_124_jr_8015C32C.c b/src/ov_SC03_124/ov_SC03_124_jr_8015C32C.c index 7d4621d2a4..9689c93cb9 100644 --- a/src/ov_SC03_124/ov_SC03_124_jr_8015C32C.c +++ b/src/ov_SC03_124/ov_SC03_124_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_124/ov_SC03_124_jr_8016AB6C.c b/src/ov_SC03_124/ov_SC03_124_jr_8016AB6C.c index 6f49b49c69..b0391568d7 100644 --- a/src/ov_SC03_124/ov_SC03_124_jr_8016AB6C.c +++ b/src/ov_SC03_124/ov_SC03_124_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_124/ov_SC03_124_jr_80171B4C.c b/src/ov_SC03_124/ov_SC03_124_jr_80171B4C.c index c82111472f..69effffe70 100644 --- a/src/ov_SC03_124/ov_SC03_124_jr_80171B4C.c +++ b/src/ov_SC03_124/ov_SC03_124_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_124/ov_SC03_124_jr_801734BC.c b/src/ov_SC03_124/ov_SC03_124_jr_801734BC.c index 3a1b587ef7..8c241e122c 100644 --- a/src/ov_SC03_124/ov_SC03_124_jr_801734BC.c +++ b/src/ov_SC03_124/ov_SC03_124_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_124/ov_SC03_124_o0c.c b/src/ov_SC03_124/ov_SC03_124_o0c.c index 0b43cf5527..9943fa6da3 100644 --- a/src/ov_SC03_124/ov_SC03_124_o0c.c +++ b/src/ov_SC03_124/ov_SC03_124_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_125/ov_SC03_125.c b/src/ov_SC03_125/ov_SC03_125.c index f58a8f0764..cb91244cc2 100644 --- a/src/ov_SC03_125/ov_SC03_125.c +++ b/src/ov_SC03_125/ov_SC03_125.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_125/ov_SC03_125_after.c b/src/ov_SC03_125/ov_SC03_125_after.c index 0d93755ac3..e3a3abdd1d 100644 --- a/src/ov_SC03_125/ov_SC03_125_after.c +++ b/src/ov_SC03_125/ov_SC03_125_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_125/ov_SC03_125_jr_8012ACE0.c b/src/ov_SC03_125/ov_SC03_125_jr_8012ACE0.c index 6808534cc6..b3029d59cf 100644 --- a/src/ov_SC03_125/ov_SC03_125_jr_8012ACE0.c +++ b/src/ov_SC03_125/ov_SC03_125_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_125/ov_SC03_125_jr_80135D20.c b/src/ov_SC03_125/ov_SC03_125_jr_80135D20.c index 02268d8214..0337c01bd5 100644 --- a/src/ov_SC03_125/ov_SC03_125_jr_80135D20.c +++ b/src/ov_SC03_125/ov_SC03_125_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_125/ov_SC03_125_jr_801380E0.c b/src/ov_SC03_125/ov_SC03_125_jr_801380E0.c index 35fce4129a..3d87cb6dad 100644 --- a/src/ov_SC03_125/ov_SC03_125_jr_801380E0.c +++ b/src/ov_SC03_125/ov_SC03_125_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 3d3cbaec26..1c047ef6c4 100644 --- a/src/ov_SC03_125/ov_SC03_125_jr_8015AE2C.c +++ b/src/ov_SC03_125/ov_SC03_125_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_125/ov_SC03_125_jr_8015C32C.c b/src/ov_SC03_125/ov_SC03_125_jr_8015C32C.c index 3e3dadebe6..04d5d78c18 100644 --- a/src/ov_SC03_125/ov_SC03_125_jr_8015C32C.c +++ b/src/ov_SC03_125/ov_SC03_125_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_125/ov_SC03_125_jr_8016AB6C.c b/src/ov_SC03_125/ov_SC03_125_jr_8016AB6C.c index 5fbdd8c682..e1448eae9f 100644 --- a/src/ov_SC03_125/ov_SC03_125_jr_8016AB6C.c +++ b/src/ov_SC03_125/ov_SC03_125_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_125/ov_SC03_125_jr_80171B4C.c b/src/ov_SC03_125/ov_SC03_125_jr_80171B4C.c index db5078ed98..1b63da9fca 100644 --- a/src/ov_SC03_125/ov_SC03_125_jr_80171B4C.c +++ b/src/ov_SC03_125/ov_SC03_125_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_125/ov_SC03_125_jr_801734BC.c b/src/ov_SC03_125/ov_SC03_125_jr_801734BC.c index f60b5a93da..0d2a6405b1 100644 --- a/src/ov_SC03_125/ov_SC03_125_jr_801734BC.c +++ b/src/ov_SC03_125/ov_SC03_125_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_125/ov_SC03_125_o0c.c b/src/ov_SC03_125/ov_SC03_125_o0c.c index 202badcb3d..67020608dd 100644 --- a/src/ov_SC03_125/ov_SC03_125_o0c.c +++ b/src/ov_SC03_125/ov_SC03_125_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC03_126/ov_SC03_126.c b/src/ov_SC03_126/ov_SC03_126.c index e781c57796..d9ac12ce5c 100644 --- a/src/ov_SC03_126/ov_SC03_126.c +++ b/src/ov_SC03_126/ov_SC03_126.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC03_126/ov_SC03_126_after.c b/src/ov_SC03_126/ov_SC03_126_after.c index 7ad57aa21f..60a258610b 100644 --- a/src/ov_SC03_126/ov_SC03_126_after.c +++ b/src/ov_SC03_126/ov_SC03_126_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC03_126/ov_SC03_126_jr_8012ACE0.c b/src/ov_SC03_126/ov_SC03_126_jr_8012ACE0.c index 47c26ec27d..a7dade676c 100644 --- a/src/ov_SC03_126/ov_SC03_126_jr_8012ACE0.c +++ b/src/ov_SC03_126/ov_SC03_126_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC03_126/ov_SC03_126_jr_80135D20.c b/src/ov_SC03_126/ov_SC03_126_jr_80135D20.c index 31e962a90f..2a3e81ef84 100644 --- a/src/ov_SC03_126/ov_SC03_126_jr_80135D20.c +++ b/src/ov_SC03_126/ov_SC03_126_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC03_126/ov_SC03_126_jr_801380E0.c b/src/ov_SC03_126/ov_SC03_126_jr_801380E0.c index f7a4937efe..7413e16f12 100644 --- a/src/ov_SC03_126/ov_SC03_126_jr_801380E0.c +++ b/src/ov_SC03_126/ov_SC03_126_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 66e07b2090..3b03999b94 100644 --- a/src/ov_SC03_126/ov_SC03_126_jr_8015AE2C.c +++ b/src/ov_SC03_126/ov_SC03_126_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC03_126/ov_SC03_126_jr_8015C32C.c b/src/ov_SC03_126/ov_SC03_126_jr_8015C32C.c index 821ad12dae..9b44d4f3c8 100644 --- a/src/ov_SC03_126/ov_SC03_126_jr_8015C32C.c +++ b/src/ov_SC03_126/ov_SC03_126_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC03_126/ov_SC03_126_jr_8016AB6C.c b/src/ov_SC03_126/ov_SC03_126_jr_8016AB6C.c index f467699ab1..d800e325fc 100644 --- a/src/ov_SC03_126/ov_SC03_126_jr_8016AB6C.c +++ b/src/ov_SC03_126/ov_SC03_126_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC03_126/ov_SC03_126_jr_80171B4C.c b/src/ov_SC03_126/ov_SC03_126_jr_80171B4C.c index 0efedcb90d..523bc322a1 100644 --- a/src/ov_SC03_126/ov_SC03_126_jr_80171B4C.c +++ b/src/ov_SC03_126/ov_SC03_126_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC03_126/ov_SC03_126_jr_801734BC.c b/src/ov_SC03_126/ov_SC03_126_jr_801734BC.c index a90976b5a1..87d8abe7c3 100644 --- a/src/ov_SC03_126/ov_SC03_126_jr_801734BC.c +++ b/src/ov_SC03_126/ov_SC03_126_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC03_126/ov_SC03_126_o0c.c b/src/ov_SC03_126/ov_SC03_126_o0c.c index e6f1498a36..395d073546 100644 --- a/src/ov_SC03_126/ov_SC03_126_o0c.c +++ b/src/ov_SC03_126/ov_SC03_126_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_000/ov_SC04_000.c b/src/ov_SC04_000/ov_SC04_000.c index 3685d38aef..576c88579d 100644 --- a/src/ov_SC04_000/ov_SC04_000.c +++ b/src/ov_SC04_000/ov_SC04_000.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_000/ov_SC04_000_after.c b/src/ov_SC04_000/ov_SC04_000_after.c index 73ad317c31..f86218e2da 100644 --- a/src/ov_SC04_000/ov_SC04_000_after.c +++ b/src/ov_SC04_000/ov_SC04_000_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_000/ov_SC04_000_jr_8012ACE0.c b/src/ov_SC04_000/ov_SC04_000_jr_8012ACE0.c index 3fc88d0a8c..dd48e15fc2 100644 --- a/src/ov_SC04_000/ov_SC04_000_jr_8012ACE0.c +++ b/src/ov_SC04_000/ov_SC04_000_jr_8012ACE0.c @@ -330,49 +330,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1107,23 +1065,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1156,29 +1098,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1940,25 +1860,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2061,15 +1963,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2101,37 +1995,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2555,35 +2419,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_000/ov_SC04_000_jr_80135D20.c b/src/ov_SC04_000/ov_SC04_000_jr_80135D20.c index dea5dc42cf..afe32a5135 100644 --- a/src/ov_SC04_000/ov_SC04_000_jr_80135D20.c +++ b/src/ov_SC04_000/ov_SC04_000_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_000/ov_SC04_000_jr_801380E0.c b/src/ov_SC04_000/ov_SC04_000_jr_801380E0.c index bbb3d17db8..a6c4cc8d2f 100644 --- a/src/ov_SC04_000/ov_SC04_000_jr_801380E0.c +++ b/src/ov_SC04_000/ov_SC04_000_jr_801380E0.c @@ -1092,43 +1092,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 89cd7932d0..2378a92524 100644 --- a/src/ov_SC04_000/ov_SC04_000_jr_8015AE2C.c +++ b/src/ov_SC04_000/ov_SC04_000_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_000/ov_SC04_000_jr_8015C32C.c b/src/ov_SC04_000/ov_SC04_000_jr_8015C32C.c index b056965903..a0fe385b18 100644 --- a/src/ov_SC04_000/ov_SC04_000_jr_8015C32C.c +++ b/src/ov_SC04_000/ov_SC04_000_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_000/ov_SC04_000_jr_8016AB6C.c b/src/ov_SC04_000/ov_SC04_000_jr_8016AB6C.c index 8633b8c6a7..334acc3bd6 100644 --- a/src/ov_SC04_000/ov_SC04_000_jr_8016AB6C.c +++ b/src/ov_SC04_000/ov_SC04_000_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_000/ov_SC04_000_jr_80171B4C.c b/src/ov_SC04_000/ov_SC04_000_jr_80171B4C.c index 24807448c8..41b096bcc4 100644 --- a/src/ov_SC04_000/ov_SC04_000_jr_80171B4C.c +++ b/src/ov_SC04_000/ov_SC04_000_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_000/ov_SC04_000_jr_801734BC.c b/src/ov_SC04_000/ov_SC04_000_jr_801734BC.c index 0f9a1a3160..813a6d6f79 100644 --- a/src/ov_SC04_000/ov_SC04_000_jr_801734BC.c +++ b/src/ov_SC04_000/ov_SC04_000_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_000/ov_SC04_000_o0c.c b/src/ov_SC04_000/ov_SC04_000_o0c.c index 1f24d9fd00..52394c73d7 100644 --- a/src/ov_SC04_000/ov_SC04_000_o0c.c +++ b/src/ov_SC04_000/ov_SC04_000_o0c.c @@ -1017,24 +1017,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_002/ov_SC04_002.c b/src/ov_SC04_002/ov_SC04_002.c index a20c2c482a..06b029f394 100644 --- a/src/ov_SC04_002/ov_SC04_002.c +++ b/src/ov_SC04_002/ov_SC04_002.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_002/ov_SC04_002_after.c b/src/ov_SC04_002/ov_SC04_002_after.c index 9a9c95a7f0..23238a7992 100644 --- a/src/ov_SC04_002/ov_SC04_002_after.c +++ b/src/ov_SC04_002/ov_SC04_002_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_002/ov_SC04_002_jr_8012ACE0.c b/src/ov_SC04_002/ov_SC04_002_jr_8012ACE0.c index 0471300613..aecf8c685a 100644 --- a/src/ov_SC04_002/ov_SC04_002_jr_8012ACE0.c +++ b/src/ov_SC04_002/ov_SC04_002_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_002/ov_SC04_002_jr_80135D20.c b/src/ov_SC04_002/ov_SC04_002_jr_80135D20.c index cb0cd05539..3b4a02bf0d 100644 --- a/src/ov_SC04_002/ov_SC04_002_jr_80135D20.c +++ b/src/ov_SC04_002/ov_SC04_002_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_002/ov_SC04_002_jr_801380E0.c b/src/ov_SC04_002/ov_SC04_002_jr_801380E0.c index 028829b2e7..2ef7c58cac 100644 --- a/src/ov_SC04_002/ov_SC04_002_jr_801380E0.c +++ b/src/ov_SC04_002/ov_SC04_002_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 bf98bd3b68..43d23e63a3 100644 --- a/src/ov_SC04_002/ov_SC04_002_jr_8015AE2C.c +++ b/src/ov_SC04_002/ov_SC04_002_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_002/ov_SC04_002_jr_8015C32C.c b/src/ov_SC04_002/ov_SC04_002_jr_8015C32C.c index bb5f627c95..5e841c8be5 100644 --- a/src/ov_SC04_002/ov_SC04_002_jr_8015C32C.c +++ b/src/ov_SC04_002/ov_SC04_002_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_002/ov_SC04_002_jr_8016AB6C.c b/src/ov_SC04_002/ov_SC04_002_jr_8016AB6C.c index 7f6dcdeb98..14786a17b9 100644 --- a/src/ov_SC04_002/ov_SC04_002_jr_8016AB6C.c +++ b/src/ov_SC04_002/ov_SC04_002_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_002/ov_SC04_002_jr_80171B4C.c b/src/ov_SC04_002/ov_SC04_002_jr_80171B4C.c index 6a90681ef3..f4f902e6b7 100644 --- a/src/ov_SC04_002/ov_SC04_002_jr_80171B4C.c +++ b/src/ov_SC04_002/ov_SC04_002_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_002/ov_SC04_002_jr_801734BC.c b/src/ov_SC04_002/ov_SC04_002_jr_801734BC.c index 56e3750700..fdf848abaa 100644 --- a/src/ov_SC04_002/ov_SC04_002_jr_801734BC.c +++ b/src/ov_SC04_002/ov_SC04_002_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_002/ov_SC04_002_o0c.c b/src/ov_SC04_002/ov_SC04_002_o0c.c index c9cb2104a1..157d2698c3 100644 --- a/src/ov_SC04_002/ov_SC04_002_o0c.c +++ b/src/ov_SC04_002/ov_SC04_002_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_003/ov_SC04_003.c b/src/ov_SC04_003/ov_SC04_003.c index 5f89da7294..0a6b8bcc5c 100644 --- a/src/ov_SC04_003/ov_SC04_003.c +++ b/src/ov_SC04_003/ov_SC04_003.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_003/ov_SC04_003_after.c b/src/ov_SC04_003/ov_SC04_003_after.c index 2448ad7e09..47397ec535 100644 --- a/src/ov_SC04_003/ov_SC04_003_after.c +++ b/src/ov_SC04_003/ov_SC04_003_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_003/ov_SC04_003_jr_8012ACE0.c b/src/ov_SC04_003/ov_SC04_003_jr_8012ACE0.c index ccd1e54391..861b870d20 100644 --- a/src/ov_SC04_003/ov_SC04_003_jr_8012ACE0.c +++ b/src/ov_SC04_003/ov_SC04_003_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_003/ov_SC04_003_jr_80135D20.c b/src/ov_SC04_003/ov_SC04_003_jr_80135D20.c index 4cf486cccf..949801fb6d 100644 --- a/src/ov_SC04_003/ov_SC04_003_jr_80135D20.c +++ b/src/ov_SC04_003/ov_SC04_003_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_003/ov_SC04_003_jr_801380E0.c b/src/ov_SC04_003/ov_SC04_003_jr_801380E0.c index bf6a8fc42c..8a6837ac17 100644 --- a/src/ov_SC04_003/ov_SC04_003_jr_801380E0.c +++ b/src/ov_SC04_003/ov_SC04_003_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 167bf45881..baf26c8903 100644 --- a/src/ov_SC04_003/ov_SC04_003_jr_8015AE2C.c +++ b/src/ov_SC04_003/ov_SC04_003_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_003/ov_SC04_003_jr_8015C32C.c b/src/ov_SC04_003/ov_SC04_003_jr_8015C32C.c index fccc79bfd7..1cd7c15fb7 100644 --- a/src/ov_SC04_003/ov_SC04_003_jr_8015C32C.c +++ b/src/ov_SC04_003/ov_SC04_003_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_003/ov_SC04_003_jr_8016AB6C.c b/src/ov_SC04_003/ov_SC04_003_jr_8016AB6C.c index bb8908a466..22c0e5f0ea 100644 --- a/src/ov_SC04_003/ov_SC04_003_jr_8016AB6C.c +++ b/src/ov_SC04_003/ov_SC04_003_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_003/ov_SC04_003_jr_80171B4C.c b/src/ov_SC04_003/ov_SC04_003_jr_80171B4C.c index 1520eceb1a..066d5c7dcb 100644 --- a/src/ov_SC04_003/ov_SC04_003_jr_80171B4C.c +++ b/src/ov_SC04_003/ov_SC04_003_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_003/ov_SC04_003_jr_801734BC.c b/src/ov_SC04_003/ov_SC04_003_jr_801734BC.c index ff1de34da7..97ae054156 100644 --- a/src/ov_SC04_003/ov_SC04_003_jr_801734BC.c +++ b/src/ov_SC04_003/ov_SC04_003_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_003/ov_SC04_003_o0c.c b/src/ov_SC04_003/ov_SC04_003_o0c.c index e79c4cde10..6b9ddba5b8 100644 --- a/src/ov_SC04_003/ov_SC04_003_o0c.c +++ b/src/ov_SC04_003/ov_SC04_003_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_004/ov_SC04_004.c b/src/ov_SC04_004/ov_SC04_004.c index ba56bc6059..9b18aaa700 100644 --- a/src/ov_SC04_004/ov_SC04_004.c +++ b/src/ov_SC04_004/ov_SC04_004.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_004/ov_SC04_004_after.c b/src/ov_SC04_004/ov_SC04_004_after.c index d876f5f6f8..c629488e81 100644 --- a/src/ov_SC04_004/ov_SC04_004_after.c +++ b/src/ov_SC04_004/ov_SC04_004_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_004/ov_SC04_004_jr_8012ACE0.c b/src/ov_SC04_004/ov_SC04_004_jr_8012ACE0.c index e41544e52c..c350d1bfba 100644 --- a/src/ov_SC04_004/ov_SC04_004_jr_8012ACE0.c +++ b/src/ov_SC04_004/ov_SC04_004_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_004/ov_SC04_004_jr_80135D20.c b/src/ov_SC04_004/ov_SC04_004_jr_80135D20.c index 0ed5fe0ecf..496374c9ed 100644 --- a/src/ov_SC04_004/ov_SC04_004_jr_80135D20.c +++ b/src/ov_SC04_004/ov_SC04_004_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_004/ov_SC04_004_jr_801380E0.c b/src/ov_SC04_004/ov_SC04_004_jr_801380E0.c index 3ce6c56e2a..b8d0c3a870 100644 --- a/src/ov_SC04_004/ov_SC04_004_jr_801380E0.c +++ b/src/ov_SC04_004/ov_SC04_004_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 705cc2622f..0a9d943586 100644 --- a/src/ov_SC04_004/ov_SC04_004_jr_8015AE2C.c +++ b/src/ov_SC04_004/ov_SC04_004_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_004/ov_SC04_004_jr_8015C32C.c b/src/ov_SC04_004/ov_SC04_004_jr_8015C32C.c index 3ef263bfb4..532093513b 100644 --- a/src/ov_SC04_004/ov_SC04_004_jr_8015C32C.c +++ b/src/ov_SC04_004/ov_SC04_004_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_004/ov_SC04_004_jr_8016AB6C.c b/src/ov_SC04_004/ov_SC04_004_jr_8016AB6C.c index 4cbdf11ec1..ec4141778d 100644 --- a/src/ov_SC04_004/ov_SC04_004_jr_8016AB6C.c +++ b/src/ov_SC04_004/ov_SC04_004_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_004/ov_SC04_004_jr_80171B4C.c b/src/ov_SC04_004/ov_SC04_004_jr_80171B4C.c index af8283f12d..b5fab57d29 100644 --- a/src/ov_SC04_004/ov_SC04_004_jr_80171B4C.c +++ b/src/ov_SC04_004/ov_SC04_004_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_004/ov_SC04_004_jr_801734BC.c b/src/ov_SC04_004/ov_SC04_004_jr_801734BC.c index 4fa681b210..b9eed3ea8b 100644 --- a/src/ov_SC04_004/ov_SC04_004_jr_801734BC.c +++ b/src/ov_SC04_004/ov_SC04_004_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_004/ov_SC04_004_o0c.c b/src/ov_SC04_004/ov_SC04_004_o0c.c index 5565a459cd..b383b4969e 100644 --- a/src/ov_SC04_004/ov_SC04_004_o0c.c +++ b/src/ov_SC04_004/ov_SC04_004_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_005/ov_SC04_005.c b/src/ov_SC04_005/ov_SC04_005.c index 0b010cc71f..c9e8d3072a 100644 --- a/src/ov_SC04_005/ov_SC04_005.c +++ b/src/ov_SC04_005/ov_SC04_005.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_005/ov_SC04_005_after.c b/src/ov_SC04_005/ov_SC04_005_after.c index 4de4b01337..fb626c52aa 100644 --- a/src/ov_SC04_005/ov_SC04_005_after.c +++ b/src/ov_SC04_005/ov_SC04_005_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_005/ov_SC04_005_jr_8012ACE0.c b/src/ov_SC04_005/ov_SC04_005_jr_8012ACE0.c index ee2b01d859..e7c83ce3e4 100644 --- a/src/ov_SC04_005/ov_SC04_005_jr_8012ACE0.c +++ b/src/ov_SC04_005/ov_SC04_005_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_005/ov_SC04_005_jr_80135D20.c b/src/ov_SC04_005/ov_SC04_005_jr_80135D20.c index a3b47ec3ce..9ae67cae80 100644 --- a/src/ov_SC04_005/ov_SC04_005_jr_80135D20.c +++ b/src/ov_SC04_005/ov_SC04_005_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_005/ov_SC04_005_jr_801380E0.c b/src/ov_SC04_005/ov_SC04_005_jr_801380E0.c index 928d66b072..0927db65cf 100644 --- a/src/ov_SC04_005/ov_SC04_005_jr_801380E0.c +++ b/src/ov_SC04_005/ov_SC04_005_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 33bc053084..39e38cd80a 100644 --- a/src/ov_SC04_005/ov_SC04_005_jr_8015AE2C.c +++ b/src/ov_SC04_005/ov_SC04_005_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_005/ov_SC04_005_jr_8015C32C.c b/src/ov_SC04_005/ov_SC04_005_jr_8015C32C.c index fd6af9276a..1c84ac8cd5 100644 --- a/src/ov_SC04_005/ov_SC04_005_jr_8015C32C.c +++ b/src/ov_SC04_005/ov_SC04_005_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_005/ov_SC04_005_jr_8016AB6C.c b/src/ov_SC04_005/ov_SC04_005_jr_8016AB6C.c index d797888edc..d426698bd6 100644 --- a/src/ov_SC04_005/ov_SC04_005_jr_8016AB6C.c +++ b/src/ov_SC04_005/ov_SC04_005_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_005/ov_SC04_005_jr_80171B4C.c b/src/ov_SC04_005/ov_SC04_005_jr_80171B4C.c index 796031f11a..0606d14554 100644 --- a/src/ov_SC04_005/ov_SC04_005_jr_80171B4C.c +++ b/src/ov_SC04_005/ov_SC04_005_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_005/ov_SC04_005_jr_801734BC.c b/src/ov_SC04_005/ov_SC04_005_jr_801734BC.c index 549e9d6903..0a03628ec1 100644 --- a/src/ov_SC04_005/ov_SC04_005_jr_801734BC.c +++ b/src/ov_SC04_005/ov_SC04_005_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_005/ov_SC04_005_o0c.c b/src/ov_SC04_005/ov_SC04_005_o0c.c index a816aa8c07..909dbb5eff 100644 --- a/src/ov_SC04_005/ov_SC04_005_o0c.c +++ b/src/ov_SC04_005/ov_SC04_005_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_006/ov_SC04_006.c b/src/ov_SC04_006/ov_SC04_006.c index 52ffb79e6a..8ec204278b 100644 --- a/src/ov_SC04_006/ov_SC04_006.c +++ b/src/ov_SC04_006/ov_SC04_006.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_006/ov_SC04_006_after.c b/src/ov_SC04_006/ov_SC04_006_after.c index 6c41400318..7fc1e906a7 100644 --- a/src/ov_SC04_006/ov_SC04_006_after.c +++ b/src/ov_SC04_006/ov_SC04_006_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_006/ov_SC04_006_jr_8012ACE0.c b/src/ov_SC04_006/ov_SC04_006_jr_8012ACE0.c index 1f4e774d9b..9ee4764954 100644 --- a/src/ov_SC04_006/ov_SC04_006_jr_8012ACE0.c +++ b/src/ov_SC04_006/ov_SC04_006_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_006/ov_SC04_006_jr_80135D20.c b/src/ov_SC04_006/ov_SC04_006_jr_80135D20.c index 77d6a00a8b..42db361132 100644 --- a/src/ov_SC04_006/ov_SC04_006_jr_80135D20.c +++ b/src/ov_SC04_006/ov_SC04_006_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_006/ov_SC04_006_jr_801380E0.c b/src/ov_SC04_006/ov_SC04_006_jr_801380E0.c index ad876dc86f..a1421192fe 100644 --- a/src/ov_SC04_006/ov_SC04_006_jr_801380E0.c +++ b/src/ov_SC04_006/ov_SC04_006_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 60480b9706..023542bd1f 100644 --- a/src/ov_SC04_006/ov_SC04_006_jr_8015AE2C.c +++ b/src/ov_SC04_006/ov_SC04_006_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_006/ov_SC04_006_jr_8015C32C.c b/src/ov_SC04_006/ov_SC04_006_jr_8015C32C.c index 716a6592d3..5656c3e0e6 100644 --- a/src/ov_SC04_006/ov_SC04_006_jr_8015C32C.c +++ b/src/ov_SC04_006/ov_SC04_006_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_006/ov_SC04_006_jr_8016AB6C.c b/src/ov_SC04_006/ov_SC04_006_jr_8016AB6C.c index b32f3f9c46..b75fa4f5c6 100644 --- a/src/ov_SC04_006/ov_SC04_006_jr_8016AB6C.c +++ b/src/ov_SC04_006/ov_SC04_006_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_006/ov_SC04_006_jr_80171B4C.c b/src/ov_SC04_006/ov_SC04_006_jr_80171B4C.c index 9e50f97cc2..e08506e578 100644 --- a/src/ov_SC04_006/ov_SC04_006_jr_80171B4C.c +++ b/src/ov_SC04_006/ov_SC04_006_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_006/ov_SC04_006_jr_801734BC.c b/src/ov_SC04_006/ov_SC04_006_jr_801734BC.c index 14a2eb6ca5..99adf12242 100644 --- a/src/ov_SC04_006/ov_SC04_006_jr_801734BC.c +++ b/src/ov_SC04_006/ov_SC04_006_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_006/ov_SC04_006_o0c.c b/src/ov_SC04_006/ov_SC04_006_o0c.c index f1851a5265..1e019401e7 100644 --- a/src/ov_SC04_006/ov_SC04_006_o0c.c +++ b/src/ov_SC04_006/ov_SC04_006_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_007/ov_SC04_007.c b/src/ov_SC04_007/ov_SC04_007.c index 5e07acf2b3..ccb407a762 100644 --- a/src/ov_SC04_007/ov_SC04_007.c +++ b/src/ov_SC04_007/ov_SC04_007.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_007/ov_SC04_007_after.c b/src/ov_SC04_007/ov_SC04_007_after.c index acf0966418..3819916360 100644 --- a/src/ov_SC04_007/ov_SC04_007_after.c +++ b/src/ov_SC04_007/ov_SC04_007_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_007/ov_SC04_007_jr_8012ACE0.c b/src/ov_SC04_007/ov_SC04_007_jr_8012ACE0.c index 42b76c62e7..f955cdd9fb 100644 --- a/src/ov_SC04_007/ov_SC04_007_jr_8012ACE0.c +++ b/src/ov_SC04_007/ov_SC04_007_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_007/ov_SC04_007_jr_80135D20.c b/src/ov_SC04_007/ov_SC04_007_jr_80135D20.c index 7374c2160b..04cd3924ec 100644 --- a/src/ov_SC04_007/ov_SC04_007_jr_80135D20.c +++ b/src/ov_SC04_007/ov_SC04_007_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_007/ov_SC04_007_jr_801380E0.c b/src/ov_SC04_007/ov_SC04_007_jr_801380E0.c index 40d4109c83..5590add573 100644 --- a/src/ov_SC04_007/ov_SC04_007_jr_801380E0.c +++ b/src/ov_SC04_007/ov_SC04_007_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 240c368626..61385f3e11 100644 --- a/src/ov_SC04_007/ov_SC04_007_jr_8015AE2C.c +++ b/src/ov_SC04_007/ov_SC04_007_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_007/ov_SC04_007_jr_8015C32C.c b/src/ov_SC04_007/ov_SC04_007_jr_8015C32C.c index 9cd11f7ef5..055b69a78e 100644 --- a/src/ov_SC04_007/ov_SC04_007_jr_8015C32C.c +++ b/src/ov_SC04_007/ov_SC04_007_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_007/ov_SC04_007_jr_8016AB6C.c b/src/ov_SC04_007/ov_SC04_007_jr_8016AB6C.c index d76ec5c782..cd1efd6934 100644 --- a/src/ov_SC04_007/ov_SC04_007_jr_8016AB6C.c +++ b/src/ov_SC04_007/ov_SC04_007_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_007/ov_SC04_007_jr_80171B4C.c b/src/ov_SC04_007/ov_SC04_007_jr_80171B4C.c index 788aa365e9..fb496d205a 100644 --- a/src/ov_SC04_007/ov_SC04_007_jr_80171B4C.c +++ b/src/ov_SC04_007/ov_SC04_007_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_007/ov_SC04_007_jr_801734BC.c b/src/ov_SC04_007/ov_SC04_007_jr_801734BC.c index 52375415e6..a30ca2ed29 100644 --- a/src/ov_SC04_007/ov_SC04_007_jr_801734BC.c +++ b/src/ov_SC04_007/ov_SC04_007_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_007/ov_SC04_007_o0c.c b/src/ov_SC04_007/ov_SC04_007_o0c.c index afa7ba0ea8..eb3d69cfcf 100644 --- a/src/ov_SC04_007/ov_SC04_007_o0c.c +++ b/src/ov_SC04_007/ov_SC04_007_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_008/ov_SC04_008.c b/src/ov_SC04_008/ov_SC04_008.c index 765c3dfa9c..e8e4e790e4 100644 --- a/src/ov_SC04_008/ov_SC04_008.c +++ b/src/ov_SC04_008/ov_SC04_008.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_008/ov_SC04_008_after.c b/src/ov_SC04_008/ov_SC04_008_after.c index 7df580c464..a022573536 100644 --- a/src/ov_SC04_008/ov_SC04_008_after.c +++ b/src/ov_SC04_008/ov_SC04_008_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ DEFINE_func_8014C568() /* dedup: shared engine-core @0x8014C568 (src/shared) */ @@ -1591,38 +1472,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2088,41 +1938,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_008/ov_SC04_008_jr_8012ACE0.c b/src/ov_SC04_008/ov_SC04_008_jr_8012ACE0.c index fd2c5b9c59..e1b27d5807 100644 --- a/src/ov_SC04_008/ov_SC04_008_jr_8012ACE0.c +++ b/src/ov_SC04_008/ov_SC04_008_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_008/ov_SC04_008_jr_80135D20.c b/src/ov_SC04_008/ov_SC04_008_jr_80135D20.c index fbf17965d3..aec00bd9a7 100644 --- a/src/ov_SC04_008/ov_SC04_008_jr_80135D20.c +++ b/src/ov_SC04_008/ov_SC04_008_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_008/ov_SC04_008_jr_801380E0.c b/src/ov_SC04_008/ov_SC04_008_jr_801380E0.c index 594b4a6bd1..7efbd0e872 100644 --- a/src/ov_SC04_008/ov_SC04_008_jr_801380E0.c +++ b/src/ov_SC04_008/ov_SC04_008_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 f941221f34..a3f7201d52 100644 --- a/src/ov_SC04_008/ov_SC04_008_jr_8015AE2C.c +++ b/src/ov_SC04_008/ov_SC04_008_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_008/ov_SC04_008_jr_8015C32C.c b/src/ov_SC04_008/ov_SC04_008_jr_8015C32C.c index bb3a7703e5..858710fe6b 100644 --- a/src/ov_SC04_008/ov_SC04_008_jr_8015C32C.c +++ b/src/ov_SC04_008/ov_SC04_008_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_008/ov_SC04_008_jr_8016AB6C.c b/src/ov_SC04_008/ov_SC04_008_jr_8016AB6C.c index 2a9efbb658..d8f2ea777f 100644 --- a/src/ov_SC04_008/ov_SC04_008_jr_8016AB6C.c +++ b/src/ov_SC04_008/ov_SC04_008_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_008/ov_SC04_008_jr_80171B4C.c b/src/ov_SC04_008/ov_SC04_008_jr_80171B4C.c index 910617fc84..5d91d89d52 100644 --- a/src/ov_SC04_008/ov_SC04_008_jr_80171B4C.c +++ b/src/ov_SC04_008/ov_SC04_008_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_008/ov_SC04_008_jr_801734BC.c b/src/ov_SC04_008/ov_SC04_008_jr_801734BC.c index 002529a14a..7fa62a9482 100644 --- a/src/ov_SC04_008/ov_SC04_008_jr_801734BC.c +++ b/src/ov_SC04_008/ov_SC04_008_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_008/ov_SC04_008_o0c.c b/src/ov_SC04_008/ov_SC04_008_o0c.c index 673b60a632..49a5e451fb 100644 --- a/src/ov_SC04_008/ov_SC04_008_o0c.c +++ b/src/ov_SC04_008/ov_SC04_008_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_009/ov_SC04_009.c b/src/ov_SC04_009/ov_SC04_009.c index 95940b4dfd..95464b4bad 100644 --- a/src/ov_SC04_009/ov_SC04_009.c +++ b/src/ov_SC04_009/ov_SC04_009.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_009/ov_SC04_009_after.c b/src/ov_SC04_009/ov_SC04_009_after.c index 27f45bbd75..91be0ebca2 100644 --- a/src/ov_SC04_009/ov_SC04_009_after.c +++ b/src/ov_SC04_009/ov_SC04_009_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_009/ov_SC04_009_jr_8012ACE0.c b/src/ov_SC04_009/ov_SC04_009_jr_8012ACE0.c index 7da0dd0f10..761a35c29a 100644 --- a/src/ov_SC04_009/ov_SC04_009_jr_8012ACE0.c +++ b/src/ov_SC04_009/ov_SC04_009_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_009/ov_SC04_009_jr_80135D20.c b/src/ov_SC04_009/ov_SC04_009_jr_80135D20.c index 2ae63685ff..e14bd22498 100644 --- a/src/ov_SC04_009/ov_SC04_009_jr_80135D20.c +++ b/src/ov_SC04_009/ov_SC04_009_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_009/ov_SC04_009_jr_801380E0.c b/src/ov_SC04_009/ov_SC04_009_jr_801380E0.c index 37c5a6b52a..fb5f290ad7 100644 --- a/src/ov_SC04_009/ov_SC04_009_jr_801380E0.c +++ b/src/ov_SC04_009/ov_SC04_009_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 de56fe34ea..81c4fed311 100644 --- a/src/ov_SC04_009/ov_SC04_009_jr_8015AE2C.c +++ b/src/ov_SC04_009/ov_SC04_009_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_009/ov_SC04_009_jr_8015C32C.c b/src/ov_SC04_009/ov_SC04_009_jr_8015C32C.c index 1ca5994bf2..e2e1f26285 100644 --- a/src/ov_SC04_009/ov_SC04_009_jr_8015C32C.c +++ b/src/ov_SC04_009/ov_SC04_009_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_009/ov_SC04_009_jr_8016AB6C.c b/src/ov_SC04_009/ov_SC04_009_jr_8016AB6C.c index 01149d8992..1c67422676 100644 --- a/src/ov_SC04_009/ov_SC04_009_jr_8016AB6C.c +++ b/src/ov_SC04_009/ov_SC04_009_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_009/ov_SC04_009_jr_80171B4C.c b/src/ov_SC04_009/ov_SC04_009_jr_80171B4C.c index 9608e5cec0..7b5da24aa3 100644 --- a/src/ov_SC04_009/ov_SC04_009_jr_80171B4C.c +++ b/src/ov_SC04_009/ov_SC04_009_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_009/ov_SC04_009_jr_801734BC.c b/src/ov_SC04_009/ov_SC04_009_jr_801734BC.c index 0278378084..fb6efe8b75 100644 --- a/src/ov_SC04_009/ov_SC04_009_jr_801734BC.c +++ b/src/ov_SC04_009/ov_SC04_009_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_009/ov_SC04_009_o0c.c b/src/ov_SC04_009/ov_SC04_009_o0c.c index 905dd27585..97504f8b0a 100644 --- a/src/ov_SC04_009/ov_SC04_009_o0c.c +++ b/src/ov_SC04_009/ov_SC04_009_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_010/ov_SC04_010.c b/src/ov_SC04_010/ov_SC04_010.c index 263acb21ef..7211db5bf7 100644 --- a/src/ov_SC04_010/ov_SC04_010.c +++ b/src/ov_SC04_010/ov_SC04_010.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_010/ov_SC04_010_after.c b/src/ov_SC04_010/ov_SC04_010_after.c index adc78d3470..8782c8392d 100644 --- a/src/ov_SC04_010/ov_SC04_010_after.c +++ b/src/ov_SC04_010/ov_SC04_010_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_010/ov_SC04_010_jr_8012ACE0.c b/src/ov_SC04_010/ov_SC04_010_jr_8012ACE0.c index 57092df791..87e39a4f74 100644 --- a/src/ov_SC04_010/ov_SC04_010_jr_8012ACE0.c +++ b/src/ov_SC04_010/ov_SC04_010_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_010/ov_SC04_010_jr_80135D20.c b/src/ov_SC04_010/ov_SC04_010_jr_80135D20.c index 434d72c38d..36026534d9 100644 --- a/src/ov_SC04_010/ov_SC04_010_jr_80135D20.c +++ b/src/ov_SC04_010/ov_SC04_010_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_010/ov_SC04_010_jr_801380E0.c b/src/ov_SC04_010/ov_SC04_010_jr_801380E0.c index 8c73e4db47..6b848f8365 100644 --- a/src/ov_SC04_010/ov_SC04_010_jr_801380E0.c +++ b/src/ov_SC04_010/ov_SC04_010_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 bf3a74af0e..79813eec6a 100644 --- a/src/ov_SC04_010/ov_SC04_010_jr_8015AE2C.c +++ b/src/ov_SC04_010/ov_SC04_010_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_010/ov_SC04_010_jr_8015C32C.c b/src/ov_SC04_010/ov_SC04_010_jr_8015C32C.c index 14d3c0f1aa..9bdfbb0342 100644 --- a/src/ov_SC04_010/ov_SC04_010_jr_8015C32C.c +++ b/src/ov_SC04_010/ov_SC04_010_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_010/ov_SC04_010_jr_8016AB6C.c b/src/ov_SC04_010/ov_SC04_010_jr_8016AB6C.c index 1814ad8990..dbc48d7bcf 100644 --- a/src/ov_SC04_010/ov_SC04_010_jr_8016AB6C.c +++ b/src/ov_SC04_010/ov_SC04_010_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_010/ov_SC04_010_jr_80171B4C.c b/src/ov_SC04_010/ov_SC04_010_jr_80171B4C.c index a911f7b1ae..0c43709b4a 100644 --- a/src/ov_SC04_010/ov_SC04_010_jr_80171B4C.c +++ b/src/ov_SC04_010/ov_SC04_010_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_010/ov_SC04_010_jr_801734BC.c b/src/ov_SC04_010/ov_SC04_010_jr_801734BC.c index 118239e776..9696deb01d 100644 --- a/src/ov_SC04_010/ov_SC04_010_jr_801734BC.c +++ b/src/ov_SC04_010/ov_SC04_010_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_010/ov_SC04_010_o0c.c b/src/ov_SC04_010/ov_SC04_010_o0c.c index 2fe11612b3..418ef43e96 100644 --- a/src/ov_SC04_010/ov_SC04_010_o0c.c +++ b/src/ov_SC04_010/ov_SC04_010_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_011/ov_SC04_011.c b/src/ov_SC04_011/ov_SC04_011.c index 605fc1f58e..e3044a32ec 100644 --- a/src/ov_SC04_011/ov_SC04_011.c +++ b/src/ov_SC04_011/ov_SC04_011.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_011/ov_SC04_011_after.c b/src/ov_SC04_011/ov_SC04_011_after.c index 1f08dc67a8..6317dfdd72 100644 --- a/src/ov_SC04_011/ov_SC04_011_after.c +++ b/src/ov_SC04_011/ov_SC04_011_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_011/ov_SC04_011_jr_8012ACE0.c b/src/ov_SC04_011/ov_SC04_011_jr_8012ACE0.c index 1dea2dd65c..1c7237a7d2 100644 --- a/src/ov_SC04_011/ov_SC04_011_jr_8012ACE0.c +++ b/src/ov_SC04_011/ov_SC04_011_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_011/ov_SC04_011_jr_80135D20.c b/src/ov_SC04_011/ov_SC04_011_jr_80135D20.c index d622b5d13b..3cc4dc6185 100644 --- a/src/ov_SC04_011/ov_SC04_011_jr_80135D20.c +++ b/src/ov_SC04_011/ov_SC04_011_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_011/ov_SC04_011_jr_801380E0.c b/src/ov_SC04_011/ov_SC04_011_jr_801380E0.c index 565235211f..da9514bd10 100644 --- a/src/ov_SC04_011/ov_SC04_011_jr_801380E0.c +++ b/src/ov_SC04_011/ov_SC04_011_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 3c2b81cee9..8bd4030577 100644 --- a/src/ov_SC04_011/ov_SC04_011_jr_8015AE2C.c +++ b/src/ov_SC04_011/ov_SC04_011_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_011/ov_SC04_011_jr_8015C32C.c b/src/ov_SC04_011/ov_SC04_011_jr_8015C32C.c index 798716d08c..0db3b57651 100644 --- a/src/ov_SC04_011/ov_SC04_011_jr_8015C32C.c +++ b/src/ov_SC04_011/ov_SC04_011_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_011/ov_SC04_011_jr_8016AB6C.c b/src/ov_SC04_011/ov_SC04_011_jr_8016AB6C.c index 859987a4c1..d59671d3a7 100644 --- a/src/ov_SC04_011/ov_SC04_011_jr_8016AB6C.c +++ b/src/ov_SC04_011/ov_SC04_011_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_011/ov_SC04_011_jr_80171B4C.c b/src/ov_SC04_011/ov_SC04_011_jr_80171B4C.c index 973833d539..4bbb180888 100644 --- a/src/ov_SC04_011/ov_SC04_011_jr_80171B4C.c +++ b/src/ov_SC04_011/ov_SC04_011_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_011/ov_SC04_011_jr_801734BC.c b/src/ov_SC04_011/ov_SC04_011_jr_801734BC.c index 1c2e78eb8d..e4cbe290f9 100644 --- a/src/ov_SC04_011/ov_SC04_011_jr_801734BC.c +++ b/src/ov_SC04_011/ov_SC04_011_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_011/ov_SC04_011_o0c.c b/src/ov_SC04_011/ov_SC04_011_o0c.c index 684272904c..8223685986 100644 --- a/src/ov_SC04_011/ov_SC04_011_o0c.c +++ b/src/ov_SC04_011/ov_SC04_011_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_012/ov_SC04_012.c b/src/ov_SC04_012/ov_SC04_012.c index 226a56e9a5..7d30a0c359 100644 --- a/src/ov_SC04_012/ov_SC04_012.c +++ b/src/ov_SC04_012/ov_SC04_012.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_012/ov_SC04_012_after.c b/src/ov_SC04_012/ov_SC04_012_after.c index 36546463b6..9126916024 100644 --- a/src/ov_SC04_012/ov_SC04_012_after.c +++ b/src/ov_SC04_012/ov_SC04_012_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_012/ov_SC04_012_jr_8012ACE0.c b/src/ov_SC04_012/ov_SC04_012_jr_8012ACE0.c index d706416cb5..15cdc1469f 100644 --- a/src/ov_SC04_012/ov_SC04_012_jr_8012ACE0.c +++ b/src/ov_SC04_012/ov_SC04_012_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_012/ov_SC04_012_jr_80135D20.c b/src/ov_SC04_012/ov_SC04_012_jr_80135D20.c index 10b42c4fa6..cbeb600218 100644 --- a/src/ov_SC04_012/ov_SC04_012_jr_80135D20.c +++ b/src/ov_SC04_012/ov_SC04_012_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_012/ov_SC04_012_jr_801380E0.c b/src/ov_SC04_012/ov_SC04_012_jr_801380E0.c index 3f00ffdec6..2b814d1839 100644 --- a/src/ov_SC04_012/ov_SC04_012_jr_801380E0.c +++ b/src/ov_SC04_012/ov_SC04_012_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 1565de8699..3fbfb7660c 100644 --- a/src/ov_SC04_012/ov_SC04_012_jr_8015AE2C.c +++ b/src/ov_SC04_012/ov_SC04_012_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_012/ov_SC04_012_jr_8015C32C.c b/src/ov_SC04_012/ov_SC04_012_jr_8015C32C.c index 249bf28601..10d040318b 100644 --- a/src/ov_SC04_012/ov_SC04_012_jr_8015C32C.c +++ b/src/ov_SC04_012/ov_SC04_012_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_012/ov_SC04_012_jr_8016AB6C.c b/src/ov_SC04_012/ov_SC04_012_jr_8016AB6C.c index e999b47bdd..b331a3967a 100644 --- a/src/ov_SC04_012/ov_SC04_012_jr_8016AB6C.c +++ b/src/ov_SC04_012/ov_SC04_012_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_012/ov_SC04_012_jr_80171B4C.c b/src/ov_SC04_012/ov_SC04_012_jr_80171B4C.c index f1a51018e1..5d01ff6430 100644 --- a/src/ov_SC04_012/ov_SC04_012_jr_80171B4C.c +++ b/src/ov_SC04_012/ov_SC04_012_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_012/ov_SC04_012_jr_801734BC.c b/src/ov_SC04_012/ov_SC04_012_jr_801734BC.c index 88498f1d75..7e64055a5f 100644 --- a/src/ov_SC04_012/ov_SC04_012_jr_801734BC.c +++ b/src/ov_SC04_012/ov_SC04_012_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_012/ov_SC04_012_o0c.c b/src/ov_SC04_012/ov_SC04_012_o0c.c index 1f07fb7fc9..02c549f9d7 100644 --- a/src/ov_SC04_012/ov_SC04_012_o0c.c +++ b/src/ov_SC04_012/ov_SC04_012_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_015/ov_SC04_015.c b/src/ov_SC04_015/ov_SC04_015.c index 44730fc52d..645ffd3f13 100644 --- a/src/ov_SC04_015/ov_SC04_015.c +++ b/src/ov_SC04_015/ov_SC04_015.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_015/ov_SC04_015_after.c b/src/ov_SC04_015/ov_SC04_015_after.c index fda0791790..2585dddd75 100644 --- a/src/ov_SC04_015/ov_SC04_015_after.c +++ b/src/ov_SC04_015/ov_SC04_015_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_015/ov_SC04_015_jr_8012ACE0.c b/src/ov_SC04_015/ov_SC04_015_jr_8012ACE0.c index a362f5d772..8aa0deb33d 100644 --- a/src/ov_SC04_015/ov_SC04_015_jr_8012ACE0.c +++ b/src/ov_SC04_015/ov_SC04_015_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_015/ov_SC04_015_jr_80135D20.c b/src/ov_SC04_015/ov_SC04_015_jr_80135D20.c index adddc9f2aa..4ee8e112bf 100644 --- a/src/ov_SC04_015/ov_SC04_015_jr_80135D20.c +++ b/src/ov_SC04_015/ov_SC04_015_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_015/ov_SC04_015_jr_801380E0.c b/src/ov_SC04_015/ov_SC04_015_jr_801380E0.c index 15a71bdd47..b41eec0c92 100644 --- a/src/ov_SC04_015/ov_SC04_015_jr_801380E0.c +++ b/src/ov_SC04_015/ov_SC04_015_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 064414c5d3..421863ecac 100644 --- a/src/ov_SC04_015/ov_SC04_015_jr_8015AE2C.c +++ b/src/ov_SC04_015/ov_SC04_015_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_015/ov_SC04_015_jr_8015C32C.c b/src/ov_SC04_015/ov_SC04_015_jr_8015C32C.c index 217d432ade..3bca78d43c 100644 --- a/src/ov_SC04_015/ov_SC04_015_jr_8015C32C.c +++ b/src/ov_SC04_015/ov_SC04_015_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_015/ov_SC04_015_jr_8016AB6C.c b/src/ov_SC04_015/ov_SC04_015_jr_8016AB6C.c index 2da6418d7f..b5491c01ec 100644 --- a/src/ov_SC04_015/ov_SC04_015_jr_8016AB6C.c +++ b/src/ov_SC04_015/ov_SC04_015_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_015/ov_SC04_015_jr_80171B4C.c b/src/ov_SC04_015/ov_SC04_015_jr_80171B4C.c index fefe461d72..deb65f1a65 100644 --- a/src/ov_SC04_015/ov_SC04_015_jr_80171B4C.c +++ b/src/ov_SC04_015/ov_SC04_015_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_015/ov_SC04_015_jr_801734BC.c b/src/ov_SC04_015/ov_SC04_015_jr_801734BC.c index 0905c0bb63..d71510e01f 100644 --- a/src/ov_SC04_015/ov_SC04_015_jr_801734BC.c +++ b/src/ov_SC04_015/ov_SC04_015_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_015/ov_SC04_015_o0c.c b/src/ov_SC04_015/ov_SC04_015_o0c.c index 859c79b69f..43c1c27dc7 100644 --- a/src/ov_SC04_015/ov_SC04_015_o0c.c +++ b/src/ov_SC04_015/ov_SC04_015_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_016/ov_SC04_016.c b/src/ov_SC04_016/ov_SC04_016.c index 5077912010..22dd50e658 100644 --- a/src/ov_SC04_016/ov_SC04_016.c +++ b/src/ov_SC04_016/ov_SC04_016.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_016/ov_SC04_016_after.c b/src/ov_SC04_016/ov_SC04_016_after.c index 775f88d118..b0e8793e02 100644 --- a/src/ov_SC04_016/ov_SC04_016_after.c +++ b/src/ov_SC04_016/ov_SC04_016_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_016/ov_SC04_016_jr_8012ACE0.c b/src/ov_SC04_016/ov_SC04_016_jr_8012ACE0.c index fa1d58c5b8..9bd65f0562 100644 --- a/src/ov_SC04_016/ov_SC04_016_jr_8012ACE0.c +++ b/src/ov_SC04_016/ov_SC04_016_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_016/ov_SC04_016_jr_80135D20.c b/src/ov_SC04_016/ov_SC04_016_jr_80135D20.c index 3e38053f38..273a65f151 100644 --- a/src/ov_SC04_016/ov_SC04_016_jr_80135D20.c +++ b/src/ov_SC04_016/ov_SC04_016_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_016/ov_SC04_016_jr_801380E0.c b/src/ov_SC04_016/ov_SC04_016_jr_801380E0.c index 43aa1282bb..c3cd3e7ecd 100644 --- a/src/ov_SC04_016/ov_SC04_016_jr_801380E0.c +++ b/src/ov_SC04_016/ov_SC04_016_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 3e8c90f171..0820f37d7a 100644 --- a/src/ov_SC04_016/ov_SC04_016_jr_8015AE2C.c +++ b/src/ov_SC04_016/ov_SC04_016_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_016/ov_SC04_016_jr_8015C32C.c b/src/ov_SC04_016/ov_SC04_016_jr_8015C32C.c index 013c041c53..6c31db7683 100644 --- a/src/ov_SC04_016/ov_SC04_016_jr_8015C32C.c +++ b/src/ov_SC04_016/ov_SC04_016_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_016/ov_SC04_016_jr_8016AB6C.c b/src/ov_SC04_016/ov_SC04_016_jr_8016AB6C.c index dbaf0a4604..b11b8bb893 100644 --- a/src/ov_SC04_016/ov_SC04_016_jr_8016AB6C.c +++ b/src/ov_SC04_016/ov_SC04_016_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_016/ov_SC04_016_jr_80171B4C.c b/src/ov_SC04_016/ov_SC04_016_jr_80171B4C.c index 7f6a8ce8d7..215f17c16f 100644 --- a/src/ov_SC04_016/ov_SC04_016_jr_80171B4C.c +++ b/src/ov_SC04_016/ov_SC04_016_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_016/ov_SC04_016_jr_801734BC.c b/src/ov_SC04_016/ov_SC04_016_jr_801734BC.c index 3557bdd25f..7a65e20327 100644 --- a/src/ov_SC04_016/ov_SC04_016_jr_801734BC.c +++ b/src/ov_SC04_016/ov_SC04_016_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_016/ov_SC04_016_o0c.c b/src/ov_SC04_016/ov_SC04_016_o0c.c index 97976337a6..9447a63976 100644 --- a/src/ov_SC04_016/ov_SC04_016_o0c.c +++ b/src/ov_SC04_016/ov_SC04_016_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_018/ov_SC04_018.c b/src/ov_SC04_018/ov_SC04_018.c index 8ed35deb90..5dd9aaf807 100644 --- a/src/ov_SC04_018/ov_SC04_018.c +++ b/src/ov_SC04_018/ov_SC04_018.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_018/ov_SC04_018_after.c b/src/ov_SC04_018/ov_SC04_018_after.c index 90e9170aaf..20fd6ac6bc 100644 --- a/src/ov_SC04_018/ov_SC04_018_after.c +++ b/src/ov_SC04_018/ov_SC04_018_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_018/ov_SC04_018_jr_8012ACE0.c b/src/ov_SC04_018/ov_SC04_018_jr_8012ACE0.c index 1595d2e7b8..51af4e8ead 100644 --- a/src/ov_SC04_018/ov_SC04_018_jr_8012ACE0.c +++ b/src/ov_SC04_018/ov_SC04_018_jr_8012ACE0.c @@ -330,49 +330,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1107,23 +1065,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1156,29 +1098,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1940,25 +1860,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2061,15 +1963,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2101,37 +1995,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2555,35 +2419,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_018/ov_SC04_018_jr_80135D20.c b/src/ov_SC04_018/ov_SC04_018_jr_80135D20.c index 60b8b645e8..38d0a46261 100644 --- a/src/ov_SC04_018/ov_SC04_018_jr_80135D20.c +++ b/src/ov_SC04_018/ov_SC04_018_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_018/ov_SC04_018_jr_801380E0.c b/src/ov_SC04_018/ov_SC04_018_jr_801380E0.c index b6cbac800d..04932077d5 100644 --- a/src/ov_SC04_018/ov_SC04_018_jr_801380E0.c +++ b/src/ov_SC04_018/ov_SC04_018_jr_801380E0.c @@ -1092,43 +1092,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 1e89094bd5..baf3282241 100644 --- a/src/ov_SC04_018/ov_SC04_018_jr_8015AE2C.c +++ b/src/ov_SC04_018/ov_SC04_018_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_018/ov_SC04_018_jr_8015C32C.c b/src/ov_SC04_018/ov_SC04_018_jr_8015C32C.c index 4c636820dc..e584e45683 100644 --- a/src/ov_SC04_018/ov_SC04_018_jr_8015C32C.c +++ b/src/ov_SC04_018/ov_SC04_018_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_018/ov_SC04_018_jr_8016AB6C.c b/src/ov_SC04_018/ov_SC04_018_jr_8016AB6C.c index 7ca80c986b..635a28881e 100644 --- a/src/ov_SC04_018/ov_SC04_018_jr_8016AB6C.c +++ b/src/ov_SC04_018/ov_SC04_018_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_018/ov_SC04_018_jr_80171B4C.c b/src/ov_SC04_018/ov_SC04_018_jr_80171B4C.c index 1c2af9e75c..4322677ea8 100644 --- a/src/ov_SC04_018/ov_SC04_018_jr_80171B4C.c +++ b/src/ov_SC04_018/ov_SC04_018_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_018/ov_SC04_018_jr_801734BC.c b/src/ov_SC04_018/ov_SC04_018_jr_801734BC.c index ab91eca354..dc7e925e97 100644 --- a/src/ov_SC04_018/ov_SC04_018_jr_801734BC.c +++ b/src/ov_SC04_018/ov_SC04_018_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_018/ov_SC04_018_o0c.c b/src/ov_SC04_018/ov_SC04_018_o0c.c index e07b65d102..9e44d6fbb2 100644 --- a/src/ov_SC04_018/ov_SC04_018_o0c.c +++ b/src/ov_SC04_018/ov_SC04_018_o0c.c @@ -1017,24 +1017,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_019/ov_SC04_019.c b/src/ov_SC04_019/ov_SC04_019.c index 8ed35deb90..5dd9aaf807 100644 --- a/src/ov_SC04_019/ov_SC04_019.c +++ b/src/ov_SC04_019/ov_SC04_019.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_019/ov_SC04_019_after.c b/src/ov_SC04_019/ov_SC04_019_after.c index 44daeff446..0b13715296 100644 --- a/src/ov_SC04_019/ov_SC04_019_after.c +++ b/src/ov_SC04_019/ov_SC04_019_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_019/ov_SC04_019_jr_8012ACE0.c b/src/ov_SC04_019/ov_SC04_019_jr_8012ACE0.c index 1595d2e7b8..51af4e8ead 100644 --- a/src/ov_SC04_019/ov_SC04_019_jr_8012ACE0.c +++ b/src/ov_SC04_019/ov_SC04_019_jr_8012ACE0.c @@ -330,49 +330,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1107,23 +1065,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1156,29 +1098,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1940,25 +1860,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2061,15 +1963,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2101,37 +1995,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2555,35 +2419,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_019/ov_SC04_019_jr_80135D20.c b/src/ov_SC04_019/ov_SC04_019_jr_80135D20.c index 60b8b645e8..38d0a46261 100644 --- a/src/ov_SC04_019/ov_SC04_019_jr_80135D20.c +++ b/src/ov_SC04_019/ov_SC04_019_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_019/ov_SC04_019_jr_801380E0.c b/src/ov_SC04_019/ov_SC04_019_jr_801380E0.c index b6cbac800d..04932077d5 100644 --- a/src/ov_SC04_019/ov_SC04_019_jr_801380E0.c +++ b/src/ov_SC04_019/ov_SC04_019_jr_801380E0.c @@ -1092,43 +1092,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 1e89094bd5..baf3282241 100644 --- a/src/ov_SC04_019/ov_SC04_019_jr_8015AE2C.c +++ b/src/ov_SC04_019/ov_SC04_019_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_019/ov_SC04_019_jr_8015C32C.c b/src/ov_SC04_019/ov_SC04_019_jr_8015C32C.c index 4c636820dc..e584e45683 100644 --- a/src/ov_SC04_019/ov_SC04_019_jr_8015C32C.c +++ b/src/ov_SC04_019/ov_SC04_019_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_019/ov_SC04_019_jr_8016AB6C.c b/src/ov_SC04_019/ov_SC04_019_jr_8016AB6C.c index 7ca80c986b..635a28881e 100644 --- a/src/ov_SC04_019/ov_SC04_019_jr_8016AB6C.c +++ b/src/ov_SC04_019/ov_SC04_019_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_019/ov_SC04_019_jr_80171B4C.c b/src/ov_SC04_019/ov_SC04_019_jr_80171B4C.c index 1c2af9e75c..4322677ea8 100644 --- a/src/ov_SC04_019/ov_SC04_019_jr_80171B4C.c +++ b/src/ov_SC04_019/ov_SC04_019_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_019/ov_SC04_019_jr_801734BC.c b/src/ov_SC04_019/ov_SC04_019_jr_801734BC.c index ab91eca354..dc7e925e97 100644 --- a/src/ov_SC04_019/ov_SC04_019_jr_801734BC.c +++ b/src/ov_SC04_019/ov_SC04_019_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_019/ov_SC04_019_o0c.c b/src/ov_SC04_019/ov_SC04_019_o0c.c index e07b65d102..9e44d6fbb2 100644 --- a/src/ov_SC04_019/ov_SC04_019_o0c.c +++ b/src/ov_SC04_019/ov_SC04_019_o0c.c @@ -1017,24 +1017,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_020/ov_SC04_020.c b/src/ov_SC04_020/ov_SC04_020.c index 74a35cb201..f3e7e9b11b 100644 --- a/src/ov_SC04_020/ov_SC04_020.c +++ b/src/ov_SC04_020/ov_SC04_020.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_020/ov_SC04_020_after.c b/src/ov_SC04_020/ov_SC04_020_after.c index 2c4d825d5a..574521b764 100644 --- a/src/ov_SC04_020/ov_SC04_020_after.c +++ b/src/ov_SC04_020/ov_SC04_020_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_020/ov_SC04_020_jr_8012ACE0.c b/src/ov_SC04_020/ov_SC04_020_jr_8012ACE0.c index 6ab0c8c6c7..e1b9704a44 100644 --- a/src/ov_SC04_020/ov_SC04_020_jr_8012ACE0.c +++ b/src/ov_SC04_020/ov_SC04_020_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_020/ov_SC04_020_jr_80135D20.c b/src/ov_SC04_020/ov_SC04_020_jr_80135D20.c index 7a7326e30c..d687d9c7ed 100644 --- a/src/ov_SC04_020/ov_SC04_020_jr_80135D20.c +++ b/src/ov_SC04_020/ov_SC04_020_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_020/ov_SC04_020_jr_801380E0.c b/src/ov_SC04_020/ov_SC04_020_jr_801380E0.c index bfb9547372..7f1b383107 100644 --- a/src/ov_SC04_020/ov_SC04_020_jr_801380E0.c +++ b/src/ov_SC04_020/ov_SC04_020_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 10a46c8895..951bc51c5d 100644 --- a/src/ov_SC04_020/ov_SC04_020_jr_8015AE2C.c +++ b/src/ov_SC04_020/ov_SC04_020_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_020/ov_SC04_020_jr_8015C32C.c b/src/ov_SC04_020/ov_SC04_020_jr_8015C32C.c index b96b4d1c1f..641f996083 100644 --- a/src/ov_SC04_020/ov_SC04_020_jr_8015C32C.c +++ b/src/ov_SC04_020/ov_SC04_020_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_020/ov_SC04_020_jr_8016AB6C.c b/src/ov_SC04_020/ov_SC04_020_jr_8016AB6C.c index 4d9cd9b5bc..385d58fbc5 100644 --- a/src/ov_SC04_020/ov_SC04_020_jr_8016AB6C.c +++ b/src/ov_SC04_020/ov_SC04_020_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_020/ov_SC04_020_jr_80171B4C.c b/src/ov_SC04_020/ov_SC04_020_jr_80171B4C.c index 9f4e8fa214..fea8b222c3 100644 --- a/src/ov_SC04_020/ov_SC04_020_jr_80171B4C.c +++ b/src/ov_SC04_020/ov_SC04_020_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_020/ov_SC04_020_jr_801734BC.c b/src/ov_SC04_020/ov_SC04_020_jr_801734BC.c index 2057087a29..ef521b3abe 100644 --- a/src/ov_SC04_020/ov_SC04_020_jr_801734BC.c +++ b/src/ov_SC04_020/ov_SC04_020_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_020/ov_SC04_020_o0c.c b/src/ov_SC04_020/ov_SC04_020_o0c.c index eb923530d3..4c396a1523 100644 --- a/src/ov_SC04_020/ov_SC04_020_o0c.c +++ b/src/ov_SC04_020/ov_SC04_020_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC04_021/ov_SC04_021.c b/src/ov_SC04_021/ov_SC04_021.c index e781c57796..d9ac12ce5c 100644 --- a/src/ov_SC04_021/ov_SC04_021.c +++ b/src/ov_SC04_021/ov_SC04_021.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC04_021/ov_SC04_021_after.c b/src/ov_SC04_021/ov_SC04_021_after.c index 4cad5f6f7d..d1d5f54b90 100644 --- a/src/ov_SC04_021/ov_SC04_021_after.c +++ b/src/ov_SC04_021/ov_SC04_021_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC04_021/ov_SC04_021_jr_8012ACE0.c b/src/ov_SC04_021/ov_SC04_021_jr_8012ACE0.c index 47c26ec27d..a7dade676c 100644 --- a/src/ov_SC04_021/ov_SC04_021_jr_8012ACE0.c +++ b/src/ov_SC04_021/ov_SC04_021_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC04_021/ov_SC04_021_jr_80135D20.c b/src/ov_SC04_021/ov_SC04_021_jr_80135D20.c index 31e962a90f..2a3e81ef84 100644 --- a/src/ov_SC04_021/ov_SC04_021_jr_80135D20.c +++ b/src/ov_SC04_021/ov_SC04_021_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC04_021/ov_SC04_021_jr_801380E0.c b/src/ov_SC04_021/ov_SC04_021_jr_801380E0.c index f7a4937efe..7413e16f12 100644 --- a/src/ov_SC04_021/ov_SC04_021_jr_801380E0.c +++ b/src/ov_SC04_021/ov_SC04_021_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 66e07b2090..3b03999b94 100644 --- a/src/ov_SC04_021/ov_SC04_021_jr_8015AE2C.c +++ b/src/ov_SC04_021/ov_SC04_021_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC04_021/ov_SC04_021_jr_8015C32C.c b/src/ov_SC04_021/ov_SC04_021_jr_8015C32C.c index 821ad12dae..9b44d4f3c8 100644 --- a/src/ov_SC04_021/ov_SC04_021_jr_8015C32C.c +++ b/src/ov_SC04_021/ov_SC04_021_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC04_021/ov_SC04_021_jr_8016AB6C.c b/src/ov_SC04_021/ov_SC04_021_jr_8016AB6C.c index f467699ab1..d800e325fc 100644 --- a/src/ov_SC04_021/ov_SC04_021_jr_8016AB6C.c +++ b/src/ov_SC04_021/ov_SC04_021_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC04_021/ov_SC04_021_jr_80171B4C.c b/src/ov_SC04_021/ov_SC04_021_jr_80171B4C.c index 0efedcb90d..523bc322a1 100644 --- a/src/ov_SC04_021/ov_SC04_021_jr_80171B4C.c +++ b/src/ov_SC04_021/ov_SC04_021_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC04_021/ov_SC04_021_jr_801734BC.c b/src/ov_SC04_021/ov_SC04_021_jr_801734BC.c index a90976b5a1..87d8abe7c3 100644 --- a/src/ov_SC04_021/ov_SC04_021_jr_801734BC.c +++ b/src/ov_SC04_021/ov_SC04_021_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC04_021/ov_SC04_021_o0c.c b/src/ov_SC04_021/ov_SC04_021_o0c.c index e6f1498a36..395d073546 100644 --- a/src/ov_SC04_021/ov_SC04_021_o0c.c +++ b/src/ov_SC04_021/ov_SC04_021_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC05_000/ov_SC05_000.c b/src/ov_SC05_000/ov_SC05_000.c index fef76dcd6c..26c06306bd 100644 --- a/src/ov_SC05_000/ov_SC05_000.c +++ b/src/ov_SC05_000/ov_SC05_000.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC05_000/ov_SC05_000_after.c b/src/ov_SC05_000/ov_SC05_000_after.c index 1e8a1f46f1..c72a0240e6 100644 --- a/src/ov_SC05_000/ov_SC05_000_after.c +++ b/src/ov_SC05_000/ov_SC05_000_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC05_000/ov_SC05_000_jr_8012ACE0.c b/src/ov_SC05_000/ov_SC05_000_jr_8012ACE0.c index 8b9ad19101..277972c67b 100644 --- a/src/ov_SC05_000/ov_SC05_000_jr_8012ACE0.c +++ b/src/ov_SC05_000/ov_SC05_000_jr_8012ACE0.c @@ -330,49 +330,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1107,23 +1065,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1156,29 +1098,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1940,25 +1860,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2061,15 +1963,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2101,37 +1995,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2555,35 +2419,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC05_000/ov_SC05_000_jr_80135D20.c b/src/ov_SC05_000/ov_SC05_000_jr_80135D20.c index d039aa243a..2c3d91529a 100644 --- a/src/ov_SC05_000/ov_SC05_000_jr_80135D20.c +++ b/src/ov_SC05_000/ov_SC05_000_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC05_000/ov_SC05_000_jr_801380E0.c b/src/ov_SC05_000/ov_SC05_000_jr_801380E0.c index 1274caf52a..b7333cf8d8 100644 --- a/src/ov_SC05_000/ov_SC05_000_jr_801380E0.c +++ b/src/ov_SC05_000/ov_SC05_000_jr_801380E0.c @@ -1092,43 +1092,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 4ddcca10fd..8ab5e79f5a 100644 --- a/src/ov_SC05_000/ov_SC05_000_jr_8015AE2C.c +++ b/src/ov_SC05_000/ov_SC05_000_jr_8015AE2C.c @@ -1813,20 +1813,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC05_000/ov_SC05_000_jr_8015C32C.c b/src/ov_SC05_000/ov_SC05_000_jr_8015C32C.c index a643fdf9f1..b20b729a2b 100644 --- a/src/ov_SC05_000/ov_SC05_000_jr_8015C32C.c +++ b/src/ov_SC05_000/ov_SC05_000_jr_8015C32C.c @@ -3351,31 +3351,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3500,58 +3476,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4187,21 +4112,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4277,51 +4188,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5391,25 +5258,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC05_000/ov_SC05_000_jr_8016AB6C.c b/src/ov_SC05_000/ov_SC05_000_jr_8016AB6C.c index 8047f2064a..3437203660 100644 --- a/src/ov_SC05_000/ov_SC05_000_jr_8016AB6C.c +++ b/src/ov_SC05_000/ov_SC05_000_jr_8016AB6C.c @@ -2552,21 +2552,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3889,37 +3875,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4284,26 +4240,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4355,38 +4292,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC05_000/ov_SC05_000_jr_80171B4C.c b/src/ov_SC05_000/ov_SC05_000_jr_80171B4C.c index 4c184ff906..081ef89aef 100644 --- a/src/ov_SC05_000/ov_SC05_000_jr_80171B4C.c +++ b/src/ov_SC05_000/ov_SC05_000_jr_80171B4C.c @@ -2420,14 +2420,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2544,18 +2537,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC05_000/ov_SC05_000_jr_801734BC.c b/src/ov_SC05_000/ov_SC05_000_jr_801734BC.c index 803a134aa6..9136e17918 100644 --- a/src/ov_SC05_000/ov_SC05_000_jr_801734BC.c +++ b/src/ov_SC05_000/ov_SC05_000_jr_801734BC.c @@ -2410,40 +2410,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2617,49 +2584,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2859,38 +2784,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2900,44 +2794,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3728,41 +3585,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC05_000/ov_SC05_000_o0c.c b/src/ov_SC05_000/ov_SC05_000_o0c.c index fef315298b..7432351e3a 100644 --- a/src/ov_SC05_000/ov_SC05_000_o0c.c +++ b/src/ov_SC05_000/ov_SC05_000_o0c.c @@ -1017,24 +1017,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC05_001/ov_SC05_001.c b/src/ov_SC05_001/ov_SC05_001.c index 5743fc00af..44414ce2f4 100644 --- a/src/ov_SC05_001/ov_SC05_001.c +++ b/src/ov_SC05_001/ov_SC05_001.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC05_001/ov_SC05_001_after.c b/src/ov_SC05_001/ov_SC05_001_after.c index 558daae512..5576cf481e 100644 --- a/src/ov_SC05_001/ov_SC05_001_after.c +++ b/src/ov_SC05_001/ov_SC05_001_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC05_001/ov_SC05_001_jr_8012ACE0.c b/src/ov_SC05_001/ov_SC05_001_jr_8012ACE0.c index 4ce4263b09..68f37d3cdf 100644 --- a/src/ov_SC05_001/ov_SC05_001_jr_8012ACE0.c +++ b/src/ov_SC05_001/ov_SC05_001_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC05_001/ov_SC05_001_jr_80135D20.c b/src/ov_SC05_001/ov_SC05_001_jr_80135D20.c index a45c8620e7..e573c75229 100644 --- a/src/ov_SC05_001/ov_SC05_001_jr_80135D20.c +++ b/src/ov_SC05_001/ov_SC05_001_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC05_001/ov_SC05_001_jr_801380E0.c b/src/ov_SC05_001/ov_SC05_001_jr_801380E0.c index f265f5b717..97a32396c4 100644 --- a/src/ov_SC05_001/ov_SC05_001_jr_801380E0.c +++ b/src/ov_SC05_001/ov_SC05_001_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 2ff1a3f6f7..0b192dc04c 100644 --- a/src/ov_SC05_001/ov_SC05_001_jr_8015AE2C.c +++ b/src/ov_SC05_001/ov_SC05_001_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC05_001/ov_SC05_001_jr_8015C32C.c b/src/ov_SC05_001/ov_SC05_001_jr_8015C32C.c index 78490cab23..7b51be9edb 100644 --- a/src/ov_SC05_001/ov_SC05_001_jr_8015C32C.c +++ b/src/ov_SC05_001/ov_SC05_001_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC05_001/ov_SC05_001_jr_8016AB6C.c b/src/ov_SC05_001/ov_SC05_001_jr_8016AB6C.c index 3af438c534..1810cb0b31 100644 --- a/src/ov_SC05_001/ov_SC05_001_jr_8016AB6C.c +++ b/src/ov_SC05_001/ov_SC05_001_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC05_001/ov_SC05_001_jr_80171B4C.c b/src/ov_SC05_001/ov_SC05_001_jr_80171B4C.c index e667350076..8c45b9f099 100644 --- a/src/ov_SC05_001/ov_SC05_001_jr_80171B4C.c +++ b/src/ov_SC05_001/ov_SC05_001_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC05_001/ov_SC05_001_jr_801734BC.c b/src/ov_SC05_001/ov_SC05_001_jr_801734BC.c index 0d6f4daaa7..458e6c5d8a 100644 --- a/src/ov_SC05_001/ov_SC05_001_jr_801734BC.c +++ b/src/ov_SC05_001/ov_SC05_001_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC05_001/ov_SC05_001_o0c.c b/src/ov_SC05_001/ov_SC05_001_o0c.c index 71bb784834..a15545072a 100644 --- a/src/ov_SC05_001/ov_SC05_001_o0c.c +++ b/src/ov_SC05_001/ov_SC05_001_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC05_002/ov_SC05_002.c b/src/ov_SC05_002/ov_SC05_002.c index 2f4347d175..52e7b7b301 100644 --- a/src/ov_SC05_002/ov_SC05_002.c +++ b/src/ov_SC05_002/ov_SC05_002.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC05_002/ov_SC05_002_after.c b/src/ov_SC05_002/ov_SC05_002_after.c index e37db940df..1cfbf153f0 100644 --- a/src/ov_SC05_002/ov_SC05_002_after.c +++ b/src/ov_SC05_002/ov_SC05_002_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC05_002/ov_SC05_002_jr_8012ACE0.c b/src/ov_SC05_002/ov_SC05_002_jr_8012ACE0.c index 04dc488fe9..996bd8099f 100644 --- a/src/ov_SC05_002/ov_SC05_002_jr_8012ACE0.c +++ b/src/ov_SC05_002/ov_SC05_002_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC05_002/ov_SC05_002_jr_80135D20.c b/src/ov_SC05_002/ov_SC05_002_jr_80135D20.c index 69ff8a0ad2..6cfe92cff2 100644 --- a/src/ov_SC05_002/ov_SC05_002_jr_80135D20.c +++ b/src/ov_SC05_002/ov_SC05_002_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC05_002/ov_SC05_002_jr_801380E0.c b/src/ov_SC05_002/ov_SC05_002_jr_801380E0.c index fb298aabf5..b6211829ee 100644 --- a/src/ov_SC05_002/ov_SC05_002_jr_801380E0.c +++ b/src/ov_SC05_002/ov_SC05_002_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 99b1edc3e4..5bf6e3289d 100644 --- a/src/ov_SC05_002/ov_SC05_002_jr_8015AE2C.c +++ b/src/ov_SC05_002/ov_SC05_002_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC05_002/ov_SC05_002_jr_8015C32C.c b/src/ov_SC05_002/ov_SC05_002_jr_8015C32C.c index c60fb89f3f..9ea3917847 100644 --- a/src/ov_SC05_002/ov_SC05_002_jr_8015C32C.c +++ b/src/ov_SC05_002/ov_SC05_002_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC05_002/ov_SC05_002_jr_8016AB6C.c b/src/ov_SC05_002/ov_SC05_002_jr_8016AB6C.c index d796272052..6d6fc6de86 100644 --- a/src/ov_SC05_002/ov_SC05_002_jr_8016AB6C.c +++ b/src/ov_SC05_002/ov_SC05_002_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC05_002/ov_SC05_002_jr_80171B4C.c b/src/ov_SC05_002/ov_SC05_002_jr_80171B4C.c index 339d49aca1..3d3e553811 100644 --- a/src/ov_SC05_002/ov_SC05_002_jr_80171B4C.c +++ b/src/ov_SC05_002/ov_SC05_002_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC05_002/ov_SC05_002_jr_801734BC.c b/src/ov_SC05_002/ov_SC05_002_jr_801734BC.c index 5cc295532d..e4b6f55ee5 100644 --- a/src/ov_SC05_002/ov_SC05_002_jr_801734BC.c +++ b/src/ov_SC05_002/ov_SC05_002_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC05_002/ov_SC05_002_o0c.c b/src/ov_SC05_002/ov_SC05_002_o0c.c index 46045f5b18..b4a6a03b24 100644 --- a/src/ov_SC05_002/ov_SC05_002_o0c.c +++ b/src/ov_SC05_002/ov_SC05_002_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC05_003/ov_SC05_003.c b/src/ov_SC05_003/ov_SC05_003.c index 2670816c6e..11b35946f6 100644 --- a/src/ov_SC05_003/ov_SC05_003.c +++ b/src/ov_SC05_003/ov_SC05_003.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC05_003/ov_SC05_003_after.c b/src/ov_SC05_003/ov_SC05_003_after.c index e7248f5f1a..086da9b362 100644 --- a/src/ov_SC05_003/ov_SC05_003_after.c +++ b/src/ov_SC05_003/ov_SC05_003_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC05_003/ov_SC05_003_jr_8012ACE0.c b/src/ov_SC05_003/ov_SC05_003_jr_8012ACE0.c index 4de46bd18f..2999e31b65 100644 --- a/src/ov_SC05_003/ov_SC05_003_jr_8012ACE0.c +++ b/src/ov_SC05_003/ov_SC05_003_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC05_003/ov_SC05_003_jr_80135D20.c b/src/ov_SC05_003/ov_SC05_003_jr_80135D20.c index f1a5778877..a2f8e98ea4 100644 --- a/src/ov_SC05_003/ov_SC05_003_jr_80135D20.c +++ b/src/ov_SC05_003/ov_SC05_003_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC05_003/ov_SC05_003_jr_801380E0.c b/src/ov_SC05_003/ov_SC05_003_jr_801380E0.c index e4e92b65a5..abfe54db6b 100644 --- a/src/ov_SC05_003/ov_SC05_003_jr_801380E0.c +++ b/src/ov_SC05_003/ov_SC05_003_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 424d235b33..6007321168 100644 --- a/src/ov_SC05_003/ov_SC05_003_jr_8015AE2C.c +++ b/src/ov_SC05_003/ov_SC05_003_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC05_003/ov_SC05_003_jr_8015C32C.c b/src/ov_SC05_003/ov_SC05_003_jr_8015C32C.c index f22227d0be..dd19a5fde6 100644 --- a/src/ov_SC05_003/ov_SC05_003_jr_8015C32C.c +++ b/src/ov_SC05_003/ov_SC05_003_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC05_003/ov_SC05_003_jr_8016AB6C.c b/src/ov_SC05_003/ov_SC05_003_jr_8016AB6C.c index 8e87e56e5f..c7c4f42708 100644 --- a/src/ov_SC05_003/ov_SC05_003_jr_8016AB6C.c +++ b/src/ov_SC05_003/ov_SC05_003_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC05_003/ov_SC05_003_jr_80171B4C.c b/src/ov_SC05_003/ov_SC05_003_jr_80171B4C.c index 8e16659064..cd649e3ffe 100644 --- a/src/ov_SC05_003/ov_SC05_003_jr_80171B4C.c +++ b/src/ov_SC05_003/ov_SC05_003_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC05_003/ov_SC05_003_jr_801734BC.c b/src/ov_SC05_003/ov_SC05_003_jr_801734BC.c index b718256b13..cbd0e406ca 100644 --- a/src/ov_SC05_003/ov_SC05_003_jr_801734BC.c +++ b/src/ov_SC05_003/ov_SC05_003_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC05_003/ov_SC05_003_o0c.c b/src/ov_SC05_003/ov_SC05_003_o0c.c index 7d97cfaacd..f183f8bd3b 100644 --- a/src/ov_SC05_003/ov_SC05_003_o0c.c +++ b/src/ov_SC05_003/ov_SC05_003_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC05_004/ov_SC05_004.c b/src/ov_SC05_004/ov_SC05_004.c index afb84b2852..2919b7bb02 100644 --- a/src/ov_SC05_004/ov_SC05_004.c +++ b/src/ov_SC05_004/ov_SC05_004.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC05_004/ov_SC05_004_after.c b/src/ov_SC05_004/ov_SC05_004_after.c index ea594ec9d0..9fc60ff0c0 100644 --- a/src/ov_SC05_004/ov_SC05_004_after.c +++ b/src/ov_SC05_004/ov_SC05_004_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC05_004/ov_SC05_004_jr_8012ACE0.c b/src/ov_SC05_004/ov_SC05_004_jr_8012ACE0.c index 70255e710b..2bb838e2f7 100644 --- a/src/ov_SC05_004/ov_SC05_004_jr_8012ACE0.c +++ b/src/ov_SC05_004/ov_SC05_004_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC05_004/ov_SC05_004_jr_80135D20.c b/src/ov_SC05_004/ov_SC05_004_jr_80135D20.c index 51512b2eaf..0a14591acb 100644 --- a/src/ov_SC05_004/ov_SC05_004_jr_80135D20.c +++ b/src/ov_SC05_004/ov_SC05_004_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC05_004/ov_SC05_004_jr_801380E0.c b/src/ov_SC05_004/ov_SC05_004_jr_801380E0.c index 04e3e9b900..98af6712d2 100644 --- a/src/ov_SC05_004/ov_SC05_004_jr_801380E0.c +++ b/src/ov_SC05_004/ov_SC05_004_jr_801380E0.c @@ -1100,43 +1100,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 a8ecc7e262..ab332fe519 100644 --- a/src/ov_SC05_004/ov_SC05_004_jr_8015AE2C.c +++ b/src/ov_SC05_004/ov_SC05_004_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC05_004/ov_SC05_004_jr_8015C32C.c b/src/ov_SC05_004/ov_SC05_004_jr_8015C32C.c index 2c40b7f9a0..95e9f083ef 100644 --- a/src/ov_SC05_004/ov_SC05_004_jr_8015C32C.c +++ b/src/ov_SC05_004/ov_SC05_004_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC05_004/ov_SC05_004_jr_8016AB6C.c b/src/ov_SC05_004/ov_SC05_004_jr_8016AB6C.c index 1b921424c4..c6b417d96f 100644 --- a/src/ov_SC05_004/ov_SC05_004_jr_8016AB6C.c +++ b/src/ov_SC05_004/ov_SC05_004_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC05_004/ov_SC05_004_jr_80171B4C.c b/src/ov_SC05_004/ov_SC05_004_jr_80171B4C.c index 220ec5c478..aa71db1f71 100644 --- a/src/ov_SC05_004/ov_SC05_004_jr_80171B4C.c +++ b/src/ov_SC05_004/ov_SC05_004_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC05_004/ov_SC05_004_jr_801734BC.c b/src/ov_SC05_004/ov_SC05_004_jr_801734BC.c index 7965516711..9eef9026f6 100644 --- a/src/ov_SC05_004/ov_SC05_004_jr_801734BC.c +++ b/src/ov_SC05_004/ov_SC05_004_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC05_004/ov_SC05_004_o0c.c b/src/ov_SC05_004/ov_SC05_004_o0c.c index c928a250f3..89ee815531 100644 --- a/src/ov_SC05_004/ov_SC05_004_o0c.c +++ b/src/ov_SC05_004/ov_SC05_004_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC05_005/ov_SC05_005.c b/src/ov_SC05_005/ov_SC05_005.c index 731eb22e82..706c83ea89 100644 --- a/src/ov_SC05_005/ov_SC05_005.c +++ b/src/ov_SC05_005/ov_SC05_005.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC05_005/ov_SC05_005_after.c b/src/ov_SC05_005/ov_SC05_005_after.c index 86b315d8c2..9fc15d8637 100644 --- a/src/ov_SC05_005/ov_SC05_005_after.c +++ b/src/ov_SC05_005/ov_SC05_005_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC05_005/ov_SC05_005_jr_8012ACE0.c b/src/ov_SC05_005/ov_SC05_005_jr_8012ACE0.c index 9a6e99d7ff..2a24dbb670 100644 --- a/src/ov_SC05_005/ov_SC05_005_jr_8012ACE0.c +++ b/src/ov_SC05_005/ov_SC05_005_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC05_005/ov_SC05_005_jr_80135D20.c b/src/ov_SC05_005/ov_SC05_005_jr_80135D20.c index 6f3386ca29..80db68dbf9 100644 --- a/src/ov_SC05_005/ov_SC05_005_jr_80135D20.c +++ b/src/ov_SC05_005/ov_SC05_005_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC05_005/ov_SC05_005_jr_801380E0.c b/src/ov_SC05_005/ov_SC05_005_jr_801380E0.c index b5e9a69319..de96e2f2af 100644 --- a/src/ov_SC05_005/ov_SC05_005_jr_801380E0.c +++ b/src/ov_SC05_005/ov_SC05_005_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 4e7fd24c1d..c598aa117d 100644 --- a/src/ov_SC05_005/ov_SC05_005_jr_8015AE2C.c +++ b/src/ov_SC05_005/ov_SC05_005_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC05_005/ov_SC05_005_jr_8015C32C.c b/src/ov_SC05_005/ov_SC05_005_jr_8015C32C.c index cd835f4f61..207b386b9d 100644 --- a/src/ov_SC05_005/ov_SC05_005_jr_8015C32C.c +++ b/src/ov_SC05_005/ov_SC05_005_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC05_005/ov_SC05_005_jr_8016AB6C.c b/src/ov_SC05_005/ov_SC05_005_jr_8016AB6C.c index 5f029e49a0..f480861e11 100644 --- a/src/ov_SC05_005/ov_SC05_005_jr_8016AB6C.c +++ b/src/ov_SC05_005/ov_SC05_005_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC05_005/ov_SC05_005_jr_80171B4C.c b/src/ov_SC05_005/ov_SC05_005_jr_80171B4C.c index b0760dce5e..cbe11770bf 100644 --- a/src/ov_SC05_005/ov_SC05_005_jr_80171B4C.c +++ b/src/ov_SC05_005/ov_SC05_005_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC05_005/ov_SC05_005_jr_801734BC.c b/src/ov_SC05_005/ov_SC05_005_jr_801734BC.c index 2c2f2f55c5..6005655565 100644 --- a/src/ov_SC05_005/ov_SC05_005_jr_801734BC.c +++ b/src/ov_SC05_005/ov_SC05_005_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC05_005/ov_SC05_005_o0c.c b/src/ov_SC05_005/ov_SC05_005_o0c.c index cadbd74a18..3f5ce4452c 100644 --- a/src/ov_SC05_005/ov_SC05_005_o0c.c +++ b/src/ov_SC05_005/ov_SC05_005_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC05_006/ov_SC05_006.c b/src/ov_SC05_006/ov_SC05_006.c index 38f7c27125..88e1c53673 100644 --- a/src/ov_SC05_006/ov_SC05_006.c +++ b/src/ov_SC05_006/ov_SC05_006.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC05_006/ov_SC05_006_after.c b/src/ov_SC05_006/ov_SC05_006_after.c index 8e165ecec8..a68e6bf6d3 100644 --- a/src/ov_SC05_006/ov_SC05_006_after.c +++ b/src/ov_SC05_006/ov_SC05_006_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC05_006/ov_SC05_006_jr_8012ACE0.c b/src/ov_SC05_006/ov_SC05_006_jr_8012ACE0.c index 8cf27a4339..09fb2d3626 100644 --- a/src/ov_SC05_006/ov_SC05_006_jr_8012ACE0.c +++ b/src/ov_SC05_006/ov_SC05_006_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC05_006/ov_SC05_006_jr_80135D20.c b/src/ov_SC05_006/ov_SC05_006_jr_80135D20.c index b0649d7984..246160b569 100644 --- a/src/ov_SC05_006/ov_SC05_006_jr_80135D20.c +++ b/src/ov_SC05_006/ov_SC05_006_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC05_006/ov_SC05_006_jr_801380E0.c b/src/ov_SC05_006/ov_SC05_006_jr_801380E0.c index c45c667879..cf7e982ff6 100644 --- a/src/ov_SC05_006/ov_SC05_006_jr_801380E0.c +++ b/src/ov_SC05_006/ov_SC05_006_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 1edcdf411b..c942a9890d 100644 --- a/src/ov_SC05_006/ov_SC05_006_jr_8015AE2C.c +++ b/src/ov_SC05_006/ov_SC05_006_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC05_006/ov_SC05_006_jr_8015C32C.c b/src/ov_SC05_006/ov_SC05_006_jr_8015C32C.c index 0680afbc37..6ec5ac0951 100644 --- a/src/ov_SC05_006/ov_SC05_006_jr_8015C32C.c +++ b/src/ov_SC05_006/ov_SC05_006_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC05_006/ov_SC05_006_jr_8016AB6C.c b/src/ov_SC05_006/ov_SC05_006_jr_8016AB6C.c index a5bfac2308..80a9754371 100644 --- a/src/ov_SC05_006/ov_SC05_006_jr_8016AB6C.c +++ b/src/ov_SC05_006/ov_SC05_006_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC05_006/ov_SC05_006_jr_80171B4C.c b/src/ov_SC05_006/ov_SC05_006_jr_80171B4C.c index 31c292a887..d10e9c389c 100644 --- a/src/ov_SC05_006/ov_SC05_006_jr_80171B4C.c +++ b/src/ov_SC05_006/ov_SC05_006_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC05_006/ov_SC05_006_jr_801734BC.c b/src/ov_SC05_006/ov_SC05_006_jr_801734BC.c index a96df4c3cd..f15ae7a38e 100644 --- a/src/ov_SC05_006/ov_SC05_006_jr_801734BC.c +++ b/src/ov_SC05_006/ov_SC05_006_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC05_006/ov_SC05_006_o0c.c b/src/ov_SC05_006/ov_SC05_006_o0c.c index c62cfe5c2d..604738d66d 100644 --- a/src/ov_SC05_006/ov_SC05_006_o0c.c +++ b/src/ov_SC05_006/ov_SC05_006_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC05_007/ov_SC05_007.c b/src/ov_SC05_007/ov_SC05_007.c index 15b5891731..f4afbc629a 100644 --- a/src/ov_SC05_007/ov_SC05_007.c +++ b/src/ov_SC05_007/ov_SC05_007.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC05_007/ov_SC05_007_after.c b/src/ov_SC05_007/ov_SC05_007_after.c index 2bd6e18cc8..26608032bc 100644 --- a/src/ov_SC05_007/ov_SC05_007_after.c +++ b/src/ov_SC05_007/ov_SC05_007_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC05_007/ov_SC05_007_jr_8012ACE0.c b/src/ov_SC05_007/ov_SC05_007_jr_8012ACE0.c index 7d7f3289a3..a46b7396e2 100644 --- a/src/ov_SC05_007/ov_SC05_007_jr_8012ACE0.c +++ b/src/ov_SC05_007/ov_SC05_007_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC05_007/ov_SC05_007_jr_80135D20.c b/src/ov_SC05_007/ov_SC05_007_jr_80135D20.c index 1c99d4bd22..a616c6f059 100644 --- a/src/ov_SC05_007/ov_SC05_007_jr_80135D20.c +++ b/src/ov_SC05_007/ov_SC05_007_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC05_007/ov_SC05_007_jr_801380E0.c b/src/ov_SC05_007/ov_SC05_007_jr_801380E0.c index d99211ef17..92b134f3ac 100644 --- a/src/ov_SC05_007/ov_SC05_007_jr_801380E0.c +++ b/src/ov_SC05_007/ov_SC05_007_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 de8025f79c..378c7fd34a 100644 --- a/src/ov_SC05_007/ov_SC05_007_jr_8015AE2C.c +++ b/src/ov_SC05_007/ov_SC05_007_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC05_007/ov_SC05_007_jr_8015C32C.c b/src/ov_SC05_007/ov_SC05_007_jr_8015C32C.c index 70dda9a5ad..846a37476b 100644 --- a/src/ov_SC05_007/ov_SC05_007_jr_8015C32C.c +++ b/src/ov_SC05_007/ov_SC05_007_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC05_007/ov_SC05_007_jr_8016AB6C.c b/src/ov_SC05_007/ov_SC05_007_jr_8016AB6C.c index 867c3b8e5b..56bcaf149c 100644 --- a/src/ov_SC05_007/ov_SC05_007_jr_8016AB6C.c +++ b/src/ov_SC05_007/ov_SC05_007_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC05_007/ov_SC05_007_jr_80171B4C.c b/src/ov_SC05_007/ov_SC05_007_jr_80171B4C.c index cf4d63171f..de12900ff1 100644 --- a/src/ov_SC05_007/ov_SC05_007_jr_80171B4C.c +++ b/src/ov_SC05_007/ov_SC05_007_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC05_007/ov_SC05_007_jr_801734BC.c b/src/ov_SC05_007/ov_SC05_007_jr_801734BC.c index 196602d18a..35441d47d5 100644 --- a/src/ov_SC05_007/ov_SC05_007_jr_801734BC.c +++ b/src/ov_SC05_007/ov_SC05_007_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC05_007/ov_SC05_007_o0c.c b/src/ov_SC05_007/ov_SC05_007_o0c.c index 2470a670fd..976f5df4f4 100644 --- a/src/ov_SC05_007/ov_SC05_007_o0c.c +++ b/src/ov_SC05_007/ov_SC05_007_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC05_008/ov_SC05_008.c b/src/ov_SC05_008/ov_SC05_008.c index 12460e34f0..1da21815d5 100644 --- a/src/ov_SC05_008/ov_SC05_008.c +++ b/src/ov_SC05_008/ov_SC05_008.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC05_008/ov_SC05_008_after.c b/src/ov_SC05_008/ov_SC05_008_after.c index 280fd50199..09b89800ae 100644 --- a/src/ov_SC05_008/ov_SC05_008_after.c +++ b/src/ov_SC05_008/ov_SC05_008_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC05_008/ov_SC05_008_jr_8012ACE0.c b/src/ov_SC05_008/ov_SC05_008_jr_8012ACE0.c index d302d1ac2c..e1bd1f4ccb 100644 --- a/src/ov_SC05_008/ov_SC05_008_jr_8012ACE0.c +++ b/src/ov_SC05_008/ov_SC05_008_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC05_008/ov_SC05_008_jr_80135D20.c b/src/ov_SC05_008/ov_SC05_008_jr_80135D20.c index 79b0793903..7e6edaeb83 100644 --- a/src/ov_SC05_008/ov_SC05_008_jr_80135D20.c +++ b/src/ov_SC05_008/ov_SC05_008_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC05_008/ov_SC05_008_jr_801380E0.c b/src/ov_SC05_008/ov_SC05_008_jr_801380E0.c index 4a12078770..1f53850fd9 100644 --- a/src/ov_SC05_008/ov_SC05_008_jr_801380E0.c +++ b/src/ov_SC05_008/ov_SC05_008_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 897bc41bd5..74957e5480 100644 --- a/src/ov_SC05_008/ov_SC05_008_jr_8015AE2C.c +++ b/src/ov_SC05_008/ov_SC05_008_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC05_008/ov_SC05_008_jr_8015C32C.c b/src/ov_SC05_008/ov_SC05_008_jr_8015C32C.c index c98c5c812d..2747627b79 100644 --- a/src/ov_SC05_008/ov_SC05_008_jr_8015C32C.c +++ b/src/ov_SC05_008/ov_SC05_008_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC05_008/ov_SC05_008_jr_8016AB6C.c b/src/ov_SC05_008/ov_SC05_008_jr_8016AB6C.c index 837ab4a320..feed44b713 100644 --- a/src/ov_SC05_008/ov_SC05_008_jr_8016AB6C.c +++ b/src/ov_SC05_008/ov_SC05_008_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC05_008/ov_SC05_008_jr_80171B4C.c b/src/ov_SC05_008/ov_SC05_008_jr_80171B4C.c index a174f41591..57aba11110 100644 --- a/src/ov_SC05_008/ov_SC05_008_jr_80171B4C.c +++ b/src/ov_SC05_008/ov_SC05_008_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC05_008/ov_SC05_008_jr_801734BC.c b/src/ov_SC05_008/ov_SC05_008_jr_801734BC.c index 2004bcb72c..395be527ff 100644 --- a/src/ov_SC05_008/ov_SC05_008_jr_801734BC.c +++ b/src/ov_SC05_008/ov_SC05_008_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC05_008/ov_SC05_008_o0c.c b/src/ov_SC05_008/ov_SC05_008_o0c.c index 6a4d9e3c1c..be16cca6ba 100644 --- a/src/ov_SC05_008/ov_SC05_008_o0c.c +++ b/src/ov_SC05_008/ov_SC05_008_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC05_009/ov_SC05_009.c b/src/ov_SC05_009/ov_SC05_009.c index 7d173a4144..ae2568275d 100644 --- a/src/ov_SC05_009/ov_SC05_009.c +++ b/src/ov_SC05_009/ov_SC05_009.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC05_009/ov_SC05_009_after.c b/src/ov_SC05_009/ov_SC05_009_after.c index bbfed6553a..7c6bd99433 100644 --- a/src/ov_SC05_009/ov_SC05_009_after.c +++ b/src/ov_SC05_009/ov_SC05_009_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ DEFINE_func_8014C568() /* dedup: shared engine-core @0x8014C568 (src/shared) */ @@ -1591,38 +1472,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2088,41 +1938,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC05_009/ov_SC05_009_jr_8012ACE0.c b/src/ov_SC05_009/ov_SC05_009_jr_8012ACE0.c index c085a84da3..aff92ae180 100644 --- a/src/ov_SC05_009/ov_SC05_009_jr_8012ACE0.c +++ b/src/ov_SC05_009/ov_SC05_009_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC05_009/ov_SC05_009_jr_80135D20.c b/src/ov_SC05_009/ov_SC05_009_jr_80135D20.c index 2219d72954..1dde92418d 100644 --- a/src/ov_SC05_009/ov_SC05_009_jr_80135D20.c +++ b/src/ov_SC05_009/ov_SC05_009_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC05_009/ov_SC05_009_jr_801380E0.c b/src/ov_SC05_009/ov_SC05_009_jr_801380E0.c index b3d63a1379..619be13c7b 100644 --- a/src/ov_SC05_009/ov_SC05_009_jr_801380E0.c +++ b/src/ov_SC05_009/ov_SC05_009_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 b589a263b5..904df5b848 100644 --- a/src/ov_SC05_009/ov_SC05_009_jr_8015AE2C.c +++ b/src/ov_SC05_009/ov_SC05_009_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC05_009/ov_SC05_009_jr_8015C32C.c b/src/ov_SC05_009/ov_SC05_009_jr_8015C32C.c index 1cb3e7336d..410b2c6a54 100644 --- a/src/ov_SC05_009/ov_SC05_009_jr_8015C32C.c +++ b/src/ov_SC05_009/ov_SC05_009_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC05_009/ov_SC05_009_jr_8016AB6C.c b/src/ov_SC05_009/ov_SC05_009_jr_8016AB6C.c index 106e5f198f..2aabb4e499 100644 --- a/src/ov_SC05_009/ov_SC05_009_jr_8016AB6C.c +++ b/src/ov_SC05_009/ov_SC05_009_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC05_009/ov_SC05_009_jr_80171B4C.c b/src/ov_SC05_009/ov_SC05_009_jr_80171B4C.c index f4b8538123..cbdc968d23 100644 --- a/src/ov_SC05_009/ov_SC05_009_jr_80171B4C.c +++ b/src/ov_SC05_009/ov_SC05_009_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC05_009/ov_SC05_009_jr_801734BC.c b/src/ov_SC05_009/ov_SC05_009_jr_801734BC.c index d76c2901eb..16c8c67306 100644 --- a/src/ov_SC05_009/ov_SC05_009_jr_801734BC.c +++ b/src/ov_SC05_009/ov_SC05_009_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC05_009/ov_SC05_009_o0c.c b/src/ov_SC05_009/ov_SC05_009_o0c.c index 4879b8dba5..62ac72bf0b 100644 --- a/src/ov_SC05_009/ov_SC05_009_o0c.c +++ b/src/ov_SC05_009/ov_SC05_009_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC05_010/ov_SC05_010.c b/src/ov_SC05_010/ov_SC05_010.c index cbb709e95b..1c5dfee24c 100644 --- a/src/ov_SC05_010/ov_SC05_010.c +++ b/src/ov_SC05_010/ov_SC05_010.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC05_010/ov_SC05_010_after.c b/src/ov_SC05_010/ov_SC05_010_after.c index 83719e580c..e5ae06f81c 100644 --- a/src/ov_SC05_010/ov_SC05_010_after.c +++ b/src/ov_SC05_010/ov_SC05_010_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC05_010/ov_SC05_010_jr_8012ACE0.c b/src/ov_SC05_010/ov_SC05_010_jr_8012ACE0.c index 1d8ed3578e..7e4919153a 100644 --- a/src/ov_SC05_010/ov_SC05_010_jr_8012ACE0.c +++ b/src/ov_SC05_010/ov_SC05_010_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC05_010/ov_SC05_010_jr_80135D20.c b/src/ov_SC05_010/ov_SC05_010_jr_80135D20.c index 9607cf8f13..aa4a43fc31 100644 --- a/src/ov_SC05_010/ov_SC05_010_jr_80135D20.c +++ b/src/ov_SC05_010/ov_SC05_010_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC05_010/ov_SC05_010_jr_801380E0.c b/src/ov_SC05_010/ov_SC05_010_jr_801380E0.c index e10edead61..b2e41b8a5e 100644 --- a/src/ov_SC05_010/ov_SC05_010_jr_801380E0.c +++ b/src/ov_SC05_010/ov_SC05_010_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 2aff0358de..cb03f0ec40 100644 --- a/src/ov_SC05_010/ov_SC05_010_jr_8015AE2C.c +++ b/src/ov_SC05_010/ov_SC05_010_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC05_010/ov_SC05_010_jr_8015C32C.c b/src/ov_SC05_010/ov_SC05_010_jr_8015C32C.c index e26b5da04b..4de30b6708 100644 --- a/src/ov_SC05_010/ov_SC05_010_jr_8015C32C.c +++ b/src/ov_SC05_010/ov_SC05_010_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC05_010/ov_SC05_010_jr_8016AB6C.c b/src/ov_SC05_010/ov_SC05_010_jr_8016AB6C.c index 82b31ba628..08d21fb671 100644 --- a/src/ov_SC05_010/ov_SC05_010_jr_8016AB6C.c +++ b/src/ov_SC05_010/ov_SC05_010_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC05_010/ov_SC05_010_jr_80171B4C.c b/src/ov_SC05_010/ov_SC05_010_jr_80171B4C.c index 4d28512b9c..f64f9d129e 100644 --- a/src/ov_SC05_010/ov_SC05_010_jr_80171B4C.c +++ b/src/ov_SC05_010/ov_SC05_010_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC05_010/ov_SC05_010_jr_801734BC.c b/src/ov_SC05_010/ov_SC05_010_jr_801734BC.c index 7c9512bf74..adc6a0b3c6 100644 --- a/src/ov_SC05_010/ov_SC05_010_jr_801734BC.c +++ b/src/ov_SC05_010/ov_SC05_010_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC05_010/ov_SC05_010_o0c.c b/src/ov_SC05_010/ov_SC05_010_o0c.c index 54ab5ce125..8094affbda 100644 --- a/src/ov_SC05_010/ov_SC05_010_o0c.c +++ b/src/ov_SC05_010/ov_SC05_010_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC05_011/ov_SC05_011.c b/src/ov_SC05_011/ov_SC05_011.c index 1744eec214..6d0686f5eb 100644 --- a/src/ov_SC05_011/ov_SC05_011.c +++ b/src/ov_SC05_011/ov_SC05_011.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC05_011/ov_SC05_011_after.c b/src/ov_SC05_011/ov_SC05_011_after.c index 1ef365fafe..5f38a76ee9 100644 --- a/src/ov_SC05_011/ov_SC05_011_after.c +++ b/src/ov_SC05_011/ov_SC05_011_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC05_011/ov_SC05_011_jr_8012ACE0.c b/src/ov_SC05_011/ov_SC05_011_jr_8012ACE0.c index d3d8eac1a2..f08a1207ab 100644 --- a/src/ov_SC05_011/ov_SC05_011_jr_8012ACE0.c +++ b/src/ov_SC05_011/ov_SC05_011_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC05_011/ov_SC05_011_jr_80135D20.c b/src/ov_SC05_011/ov_SC05_011_jr_80135D20.c index f0f7eb69a7..2c0a235f0f 100644 --- a/src/ov_SC05_011/ov_SC05_011_jr_80135D20.c +++ b/src/ov_SC05_011/ov_SC05_011_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC05_011/ov_SC05_011_jr_801380E0.c b/src/ov_SC05_011/ov_SC05_011_jr_801380E0.c index 8926822737..35ce686c74 100644 --- a/src/ov_SC05_011/ov_SC05_011_jr_801380E0.c +++ b/src/ov_SC05_011/ov_SC05_011_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 2fce2f1039..779c9548e3 100644 --- a/src/ov_SC05_011/ov_SC05_011_jr_8015AE2C.c +++ b/src/ov_SC05_011/ov_SC05_011_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC05_011/ov_SC05_011_jr_8015C32C.c b/src/ov_SC05_011/ov_SC05_011_jr_8015C32C.c index 41e9a96478..fd807d3397 100644 --- a/src/ov_SC05_011/ov_SC05_011_jr_8015C32C.c +++ b/src/ov_SC05_011/ov_SC05_011_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC05_011/ov_SC05_011_jr_8016AB6C.c b/src/ov_SC05_011/ov_SC05_011_jr_8016AB6C.c index 6dd8c981b9..2c2bf03f6b 100644 --- a/src/ov_SC05_011/ov_SC05_011_jr_8016AB6C.c +++ b/src/ov_SC05_011/ov_SC05_011_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC05_011/ov_SC05_011_jr_80171B4C.c b/src/ov_SC05_011/ov_SC05_011_jr_80171B4C.c index a7769721f4..2eab2e6de7 100644 --- a/src/ov_SC05_011/ov_SC05_011_jr_80171B4C.c +++ b/src/ov_SC05_011/ov_SC05_011_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC05_011/ov_SC05_011_jr_801734BC.c b/src/ov_SC05_011/ov_SC05_011_jr_801734BC.c index b5e10f3d94..58f8a3233d 100644 --- a/src/ov_SC05_011/ov_SC05_011_jr_801734BC.c +++ b/src/ov_SC05_011/ov_SC05_011_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC05_011/ov_SC05_011_o0c.c b/src/ov_SC05_011/ov_SC05_011_o0c.c index 9aa98793e7..3c8a06378c 100644 --- a/src/ov_SC05_011/ov_SC05_011_o0c.c +++ b/src/ov_SC05_011/ov_SC05_011_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC05_017/ov_SC05_017.c b/src/ov_SC05_017/ov_SC05_017.c index 250da31436..7f53182c73 100644 --- a/src/ov_SC05_017/ov_SC05_017.c +++ b/src/ov_SC05_017/ov_SC05_017.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC05_017/ov_SC05_017_after.c b/src/ov_SC05_017/ov_SC05_017_after.c index 563e716332..ce275e7a93 100644 --- a/src/ov_SC05_017/ov_SC05_017_after.c +++ b/src/ov_SC05_017/ov_SC05_017_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC05_017/ov_SC05_017_jr_8012ACE0.c b/src/ov_SC05_017/ov_SC05_017_jr_8012ACE0.c index 6f6cbe48bc..7da575443e 100644 --- a/src/ov_SC05_017/ov_SC05_017_jr_8012ACE0.c +++ b/src/ov_SC05_017/ov_SC05_017_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC05_017/ov_SC05_017_jr_80135D20.c b/src/ov_SC05_017/ov_SC05_017_jr_80135D20.c index a9a1e4a468..c0e79e4af7 100644 --- a/src/ov_SC05_017/ov_SC05_017_jr_80135D20.c +++ b/src/ov_SC05_017/ov_SC05_017_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC05_017/ov_SC05_017_jr_801380E0.c b/src/ov_SC05_017/ov_SC05_017_jr_801380E0.c index 6cea236ce5..2e9f117c2a 100644 --- a/src/ov_SC05_017/ov_SC05_017_jr_801380E0.c +++ b/src/ov_SC05_017/ov_SC05_017_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 c240fd033c..81c8ea3141 100644 --- a/src/ov_SC05_017/ov_SC05_017_jr_8015AE2C.c +++ b/src/ov_SC05_017/ov_SC05_017_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC05_017/ov_SC05_017_jr_8015C32C.c b/src/ov_SC05_017/ov_SC05_017_jr_8015C32C.c index 12d8ee8d13..1daa9b1295 100644 --- a/src/ov_SC05_017/ov_SC05_017_jr_8015C32C.c +++ b/src/ov_SC05_017/ov_SC05_017_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC05_017/ov_SC05_017_jr_8016AB6C.c b/src/ov_SC05_017/ov_SC05_017_jr_8016AB6C.c index 38b110aa4f..01855acfc3 100644 --- a/src/ov_SC05_017/ov_SC05_017_jr_8016AB6C.c +++ b/src/ov_SC05_017/ov_SC05_017_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC05_017/ov_SC05_017_jr_80171B4C.c b/src/ov_SC05_017/ov_SC05_017_jr_80171B4C.c index de0f7ad019..5024ffe7c9 100644 --- a/src/ov_SC05_017/ov_SC05_017_jr_80171B4C.c +++ b/src/ov_SC05_017/ov_SC05_017_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC05_017/ov_SC05_017_jr_801734BC.c b/src/ov_SC05_017/ov_SC05_017_jr_801734BC.c index ff025e5e46..ca78e19537 100644 --- a/src/ov_SC05_017/ov_SC05_017_jr_801734BC.c +++ b/src/ov_SC05_017/ov_SC05_017_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC05_017/ov_SC05_017_o0c.c b/src/ov_SC05_017/ov_SC05_017_o0c.c index c7a259c3a0..b9c28a8416 100644 --- a/src/ov_SC05_017/ov_SC05_017_o0c.c +++ b/src/ov_SC05_017/ov_SC05_017_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC05_018/ov_SC05_018.c b/src/ov_SC05_018/ov_SC05_018.c index 376fb3c6b6..9c9c18fbb0 100644 --- a/src/ov_SC05_018/ov_SC05_018.c +++ b/src/ov_SC05_018/ov_SC05_018.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC05_018/ov_SC05_018_after.c b/src/ov_SC05_018/ov_SC05_018_after.c index 83b03fdd59..414a8bfa58 100644 --- a/src/ov_SC05_018/ov_SC05_018_after.c +++ b/src/ov_SC05_018/ov_SC05_018_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC05_018/ov_SC05_018_jr_8012ACE0.c b/src/ov_SC05_018/ov_SC05_018_jr_8012ACE0.c index 77f16196c7..67416b3c2a 100644 --- a/src/ov_SC05_018/ov_SC05_018_jr_8012ACE0.c +++ b/src/ov_SC05_018/ov_SC05_018_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC05_018/ov_SC05_018_jr_80135D20.c b/src/ov_SC05_018/ov_SC05_018_jr_80135D20.c index d17ee23fdd..8275deed73 100644 --- a/src/ov_SC05_018/ov_SC05_018_jr_80135D20.c +++ b/src/ov_SC05_018/ov_SC05_018_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC05_018/ov_SC05_018_jr_801380E0.c b/src/ov_SC05_018/ov_SC05_018_jr_801380E0.c index d450b5657c..185a66b245 100644 --- a/src/ov_SC05_018/ov_SC05_018_jr_801380E0.c +++ b/src/ov_SC05_018/ov_SC05_018_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 3d1f0a378b..445e3cb610 100644 --- a/src/ov_SC05_018/ov_SC05_018_jr_8015AE2C.c +++ b/src/ov_SC05_018/ov_SC05_018_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC05_018/ov_SC05_018_jr_8015C32C.c b/src/ov_SC05_018/ov_SC05_018_jr_8015C32C.c index 359d92f663..4328bd43bb 100644 --- a/src/ov_SC05_018/ov_SC05_018_jr_8015C32C.c +++ b/src/ov_SC05_018/ov_SC05_018_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC05_018/ov_SC05_018_jr_8016AB6C.c b/src/ov_SC05_018/ov_SC05_018_jr_8016AB6C.c index 1d2fa0099f..69ec67f2b5 100644 --- a/src/ov_SC05_018/ov_SC05_018_jr_8016AB6C.c +++ b/src/ov_SC05_018/ov_SC05_018_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC05_018/ov_SC05_018_jr_80171B4C.c b/src/ov_SC05_018/ov_SC05_018_jr_80171B4C.c index ac22ff4f02..f01ed0cd79 100644 --- a/src/ov_SC05_018/ov_SC05_018_jr_80171B4C.c +++ b/src/ov_SC05_018/ov_SC05_018_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC05_018/ov_SC05_018_jr_801734BC.c b/src/ov_SC05_018/ov_SC05_018_jr_801734BC.c index 963ba32cfe..911c9ad390 100644 --- a/src/ov_SC05_018/ov_SC05_018_jr_801734BC.c +++ b/src/ov_SC05_018/ov_SC05_018_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC05_018/ov_SC05_018_o0c.c b/src/ov_SC05_018/ov_SC05_018_o0c.c index 31e7690d53..2367169a1e 100644 --- a/src/ov_SC05_018/ov_SC05_018_o0c.c +++ b/src/ov_SC05_018/ov_SC05_018_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC05_019/ov_SC05_019.c b/src/ov_SC05_019/ov_SC05_019.c index e781c57796..d9ac12ce5c 100644 --- a/src/ov_SC05_019/ov_SC05_019.c +++ b/src/ov_SC05_019/ov_SC05_019.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC05_019/ov_SC05_019_after.c b/src/ov_SC05_019/ov_SC05_019_after.c index e795f76f7a..47eb298f19 100644 --- a/src/ov_SC05_019/ov_SC05_019_after.c +++ b/src/ov_SC05_019/ov_SC05_019_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC05_019/ov_SC05_019_jr_8012ACE0.c b/src/ov_SC05_019/ov_SC05_019_jr_8012ACE0.c index 47c26ec27d..a7dade676c 100644 --- a/src/ov_SC05_019/ov_SC05_019_jr_8012ACE0.c +++ b/src/ov_SC05_019/ov_SC05_019_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC05_019/ov_SC05_019_jr_80135D20.c b/src/ov_SC05_019/ov_SC05_019_jr_80135D20.c index 31e962a90f..2a3e81ef84 100644 --- a/src/ov_SC05_019/ov_SC05_019_jr_80135D20.c +++ b/src/ov_SC05_019/ov_SC05_019_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC05_019/ov_SC05_019_jr_801380E0.c b/src/ov_SC05_019/ov_SC05_019_jr_801380E0.c index f7a4937efe..7413e16f12 100644 --- a/src/ov_SC05_019/ov_SC05_019_jr_801380E0.c +++ b/src/ov_SC05_019/ov_SC05_019_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 66e07b2090..3b03999b94 100644 --- a/src/ov_SC05_019/ov_SC05_019_jr_8015AE2C.c +++ b/src/ov_SC05_019/ov_SC05_019_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC05_019/ov_SC05_019_jr_8015C32C.c b/src/ov_SC05_019/ov_SC05_019_jr_8015C32C.c index 821ad12dae..9b44d4f3c8 100644 --- a/src/ov_SC05_019/ov_SC05_019_jr_8015C32C.c +++ b/src/ov_SC05_019/ov_SC05_019_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC05_019/ov_SC05_019_jr_8016AB6C.c b/src/ov_SC05_019/ov_SC05_019_jr_8016AB6C.c index f467699ab1..d800e325fc 100644 --- a/src/ov_SC05_019/ov_SC05_019_jr_8016AB6C.c +++ b/src/ov_SC05_019/ov_SC05_019_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC05_019/ov_SC05_019_jr_80171B4C.c b/src/ov_SC05_019/ov_SC05_019_jr_80171B4C.c index 0efedcb90d..523bc322a1 100644 --- a/src/ov_SC05_019/ov_SC05_019_jr_80171B4C.c +++ b/src/ov_SC05_019/ov_SC05_019_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC05_019/ov_SC05_019_jr_801734BC.c b/src/ov_SC05_019/ov_SC05_019_jr_801734BC.c index a90976b5a1..87d8abe7c3 100644 --- a/src/ov_SC05_019/ov_SC05_019_jr_801734BC.c +++ b/src/ov_SC05_019/ov_SC05_019_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC05_019/ov_SC05_019_o0c.c b/src/ov_SC05_019/ov_SC05_019_o0c.c index e6f1498a36..395d073546 100644 --- a/src/ov_SC05_019/ov_SC05_019_o0c.c +++ b/src/ov_SC05_019/ov_SC05_019_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_000/ov_SC06_000.c b/src/ov_SC06_000/ov_SC06_000.c index 52c4453976..bfd215c242 100644 --- a/src/ov_SC06_000/ov_SC06_000.c +++ b/src/ov_SC06_000/ov_SC06_000.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_000/ov_SC06_000_after.c b/src/ov_SC06_000/ov_SC06_000_after.c index 2fa2955754..10e3ce3352 100644 --- a/src/ov_SC06_000/ov_SC06_000_after.c +++ b/src/ov_SC06_000/ov_SC06_000_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_000/ov_SC06_000_jr_8012ACE0.c b/src/ov_SC06_000/ov_SC06_000_jr_8012ACE0.c index 0e985f0020..8be6494a88 100644 --- a/src/ov_SC06_000/ov_SC06_000_jr_8012ACE0.c +++ b/src/ov_SC06_000/ov_SC06_000_jr_8012ACE0.c @@ -330,49 +330,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1107,23 +1065,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1156,29 +1098,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1940,25 +1860,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2061,15 +1963,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2101,37 +1995,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2555,35 +2419,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_000/ov_SC06_000_jr_80135D20.c b/src/ov_SC06_000/ov_SC06_000_jr_80135D20.c index 940b081424..4b4c49e4f8 100644 --- a/src/ov_SC06_000/ov_SC06_000_jr_80135D20.c +++ b/src/ov_SC06_000/ov_SC06_000_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_000/ov_SC06_000_jr_801380E0.c b/src/ov_SC06_000/ov_SC06_000_jr_801380E0.c index 524748d9ea..d102689758 100644 --- a/src/ov_SC06_000/ov_SC06_000_jr_801380E0.c +++ b/src/ov_SC06_000/ov_SC06_000_jr_801380E0.c @@ -1095,43 +1095,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 ff88358f17..2aca0d6cb0 100644 --- a/src/ov_SC06_000/ov_SC06_000_jr_8015AE2C.c +++ b/src/ov_SC06_000/ov_SC06_000_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_000/ov_SC06_000_jr_8015C32C.c b/src/ov_SC06_000/ov_SC06_000_jr_8015C32C.c index 4d79dd99b0..f75a6a207d 100644 --- a/src/ov_SC06_000/ov_SC06_000_jr_8015C32C.c +++ b/src/ov_SC06_000/ov_SC06_000_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_000/ov_SC06_000_jr_8016AB6C.c b/src/ov_SC06_000/ov_SC06_000_jr_8016AB6C.c index deed3ba1a9..87be573599 100644 --- a/src/ov_SC06_000/ov_SC06_000_jr_8016AB6C.c +++ b/src/ov_SC06_000/ov_SC06_000_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_000/ov_SC06_000_jr_80171B4C.c b/src/ov_SC06_000/ov_SC06_000_jr_80171B4C.c index 4dc81a3cac..935902efda 100644 --- a/src/ov_SC06_000/ov_SC06_000_jr_80171B4C.c +++ b/src/ov_SC06_000/ov_SC06_000_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_000/ov_SC06_000_jr_801734BC.c b/src/ov_SC06_000/ov_SC06_000_jr_801734BC.c index 04d0fc3ce0..0d2b2adad7 100644 --- a/src/ov_SC06_000/ov_SC06_000_jr_801734BC.c +++ b/src/ov_SC06_000/ov_SC06_000_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_000/ov_SC06_000_o0c.c b/src/ov_SC06_000/ov_SC06_000_o0c.c index e21bd54ae6..0048c60cac 100644 --- a/src/ov_SC06_000/ov_SC06_000_o0c.c +++ b/src/ov_SC06_000/ov_SC06_000_o0c.c @@ -1020,24 +1020,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_006/ov_SC06_006.c b/src/ov_SC06_006/ov_SC06_006.c index 31f0bb2304..7fc6edb2d4 100644 --- a/src/ov_SC06_006/ov_SC06_006.c +++ b/src/ov_SC06_006/ov_SC06_006.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_006/ov_SC06_006_after.c b/src/ov_SC06_006/ov_SC06_006_after.c index 09ea2ec593..c4c0af3761 100644 --- a/src/ov_SC06_006/ov_SC06_006_after.c +++ b/src/ov_SC06_006/ov_SC06_006_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_006/ov_SC06_006_jr_8012ACE0.c b/src/ov_SC06_006/ov_SC06_006_jr_8012ACE0.c index 509b1443af..0945488279 100644 --- a/src/ov_SC06_006/ov_SC06_006_jr_8012ACE0.c +++ b/src/ov_SC06_006/ov_SC06_006_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_006/ov_SC06_006_jr_80135D20.c b/src/ov_SC06_006/ov_SC06_006_jr_80135D20.c index 008136e924..bac76ae516 100644 --- a/src/ov_SC06_006/ov_SC06_006_jr_80135D20.c +++ b/src/ov_SC06_006/ov_SC06_006_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_006/ov_SC06_006_jr_801380E0.c b/src/ov_SC06_006/ov_SC06_006_jr_801380E0.c index 4799671a9b..2c507584ca 100644 --- a/src/ov_SC06_006/ov_SC06_006_jr_801380E0.c +++ b/src/ov_SC06_006/ov_SC06_006_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 7a36750d22..0653dcde56 100644 --- a/src/ov_SC06_006/ov_SC06_006_jr_8015AE2C.c +++ b/src/ov_SC06_006/ov_SC06_006_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_006/ov_SC06_006_jr_8015C32C.c b/src/ov_SC06_006/ov_SC06_006_jr_8015C32C.c index 0fec7c07bd..6ec6dc7654 100644 --- a/src/ov_SC06_006/ov_SC06_006_jr_8015C32C.c +++ b/src/ov_SC06_006/ov_SC06_006_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_006/ov_SC06_006_jr_8016AB6C.c b/src/ov_SC06_006/ov_SC06_006_jr_8016AB6C.c index e5b91863b0..b327da17c5 100644 --- a/src/ov_SC06_006/ov_SC06_006_jr_8016AB6C.c +++ b/src/ov_SC06_006/ov_SC06_006_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_006/ov_SC06_006_jr_80171B4C.c b/src/ov_SC06_006/ov_SC06_006_jr_80171B4C.c index a0613e7b1a..f843f226c2 100644 --- a/src/ov_SC06_006/ov_SC06_006_jr_80171B4C.c +++ b/src/ov_SC06_006/ov_SC06_006_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_006/ov_SC06_006_jr_801734BC.c b/src/ov_SC06_006/ov_SC06_006_jr_801734BC.c index 307da2406c..a3f32e210b 100644 --- a/src/ov_SC06_006/ov_SC06_006_jr_801734BC.c +++ b/src/ov_SC06_006/ov_SC06_006_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_006/ov_SC06_006_o0c.c b/src/ov_SC06_006/ov_SC06_006_o0c.c index a6f110bab4..232450f76f 100644 --- a/src/ov_SC06_006/ov_SC06_006_o0c.c +++ b/src/ov_SC06_006/ov_SC06_006_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_008/ov_SC06_008.c b/src/ov_SC06_008/ov_SC06_008.c index dcffbf6aa1..c0119da719 100644 --- a/src/ov_SC06_008/ov_SC06_008.c +++ b/src/ov_SC06_008/ov_SC06_008.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_008/ov_SC06_008_after.c b/src/ov_SC06_008/ov_SC06_008_after.c index 1d9a505187..c24f719899 100644 --- a/src/ov_SC06_008/ov_SC06_008_after.c +++ b/src/ov_SC06_008/ov_SC06_008_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_008/ov_SC06_008_jr_8012ACE0.c b/src/ov_SC06_008/ov_SC06_008_jr_8012ACE0.c index d7082002ce..a96ff8a593 100644 --- a/src/ov_SC06_008/ov_SC06_008_jr_8012ACE0.c +++ b/src/ov_SC06_008/ov_SC06_008_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_008/ov_SC06_008_jr_80135D20.c b/src/ov_SC06_008/ov_SC06_008_jr_80135D20.c index 157764f198..4788f2c82c 100644 --- a/src/ov_SC06_008/ov_SC06_008_jr_80135D20.c +++ b/src/ov_SC06_008/ov_SC06_008_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_008/ov_SC06_008_jr_801380E0.c b/src/ov_SC06_008/ov_SC06_008_jr_801380E0.c index cb8ed53087..78d5d31bd7 100644 --- a/src/ov_SC06_008/ov_SC06_008_jr_801380E0.c +++ b/src/ov_SC06_008/ov_SC06_008_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 2f4dd51bd0..41a44415b4 100644 --- a/src/ov_SC06_008/ov_SC06_008_jr_8015AE2C.c +++ b/src/ov_SC06_008/ov_SC06_008_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_008/ov_SC06_008_jr_8015C32C.c b/src/ov_SC06_008/ov_SC06_008_jr_8015C32C.c index c7b9b84d57..92de9a1fe8 100644 --- a/src/ov_SC06_008/ov_SC06_008_jr_8015C32C.c +++ b/src/ov_SC06_008/ov_SC06_008_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_008/ov_SC06_008_jr_8016AB6C.c b/src/ov_SC06_008/ov_SC06_008_jr_8016AB6C.c index 84f49c2281..7bc4c06266 100644 --- a/src/ov_SC06_008/ov_SC06_008_jr_8016AB6C.c +++ b/src/ov_SC06_008/ov_SC06_008_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_008/ov_SC06_008_jr_80171B4C.c b/src/ov_SC06_008/ov_SC06_008_jr_80171B4C.c index bda84982d1..f79218e466 100644 --- a/src/ov_SC06_008/ov_SC06_008_jr_80171B4C.c +++ b/src/ov_SC06_008/ov_SC06_008_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_008/ov_SC06_008_jr_801734BC.c b/src/ov_SC06_008/ov_SC06_008_jr_801734BC.c index 2e79008a38..f7598557de 100644 --- a/src/ov_SC06_008/ov_SC06_008_jr_801734BC.c +++ b/src/ov_SC06_008/ov_SC06_008_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_008/ov_SC06_008_o0c.c b/src/ov_SC06_008/ov_SC06_008_o0c.c index 7303ccd592..b6ca803595 100644 --- a/src/ov_SC06_008/ov_SC06_008_o0c.c +++ b/src/ov_SC06_008/ov_SC06_008_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_010/ov_SC06_010.c b/src/ov_SC06_010/ov_SC06_010.c index a9312d849d..b6d7732d71 100644 --- a/src/ov_SC06_010/ov_SC06_010.c +++ b/src/ov_SC06_010/ov_SC06_010.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_010/ov_SC06_010_after.c b/src/ov_SC06_010/ov_SC06_010_after.c index a7cc35397c..e10858a7be 100644 --- a/src/ov_SC06_010/ov_SC06_010_after.c +++ b/src/ov_SC06_010/ov_SC06_010_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_010/ov_SC06_010_jr_8012ACE0.c b/src/ov_SC06_010/ov_SC06_010_jr_8012ACE0.c index a9fc451cb2..96edc61c14 100644 --- a/src/ov_SC06_010/ov_SC06_010_jr_8012ACE0.c +++ b/src/ov_SC06_010/ov_SC06_010_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_010/ov_SC06_010_jr_80135D20.c b/src/ov_SC06_010/ov_SC06_010_jr_80135D20.c index 681b8a4929..e925d2d1c8 100644 --- a/src/ov_SC06_010/ov_SC06_010_jr_80135D20.c +++ b/src/ov_SC06_010/ov_SC06_010_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_010/ov_SC06_010_jr_801380E0.c b/src/ov_SC06_010/ov_SC06_010_jr_801380E0.c index 73bc0aa3ba..60bd3f48cd 100644 --- a/src/ov_SC06_010/ov_SC06_010_jr_801380E0.c +++ b/src/ov_SC06_010/ov_SC06_010_jr_801380E0.c @@ -1100,43 +1100,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 296c03b7e5..15902cf7f1 100644 --- a/src/ov_SC06_010/ov_SC06_010_jr_8015AE2C.c +++ b/src/ov_SC06_010/ov_SC06_010_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_010/ov_SC06_010_jr_8015C32C.c b/src/ov_SC06_010/ov_SC06_010_jr_8015C32C.c index db30329abb..b998d7ca70 100644 --- a/src/ov_SC06_010/ov_SC06_010_jr_8015C32C.c +++ b/src/ov_SC06_010/ov_SC06_010_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_010/ov_SC06_010_jr_8016AB6C.c b/src/ov_SC06_010/ov_SC06_010_jr_8016AB6C.c index d7a5725d68..cebc3219bf 100644 --- a/src/ov_SC06_010/ov_SC06_010_jr_8016AB6C.c +++ b/src/ov_SC06_010/ov_SC06_010_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_010/ov_SC06_010_jr_80171B4C.c b/src/ov_SC06_010/ov_SC06_010_jr_80171B4C.c index 7e6808e808..ce33a5a5c6 100644 --- a/src/ov_SC06_010/ov_SC06_010_jr_80171B4C.c +++ b/src/ov_SC06_010/ov_SC06_010_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_010/ov_SC06_010_jr_801734BC.c b/src/ov_SC06_010/ov_SC06_010_jr_801734BC.c index 9df6372d8d..280538d262 100644 --- a/src/ov_SC06_010/ov_SC06_010_jr_801734BC.c +++ b/src/ov_SC06_010/ov_SC06_010_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_010/ov_SC06_010_o0c.c b/src/ov_SC06_010/ov_SC06_010_o0c.c index 33bafa48bf..01522e9fd2 100644 --- a/src/ov_SC06_010/ov_SC06_010_o0c.c +++ b/src/ov_SC06_010/ov_SC06_010_o0c.c @@ -1018,24 +1018,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_011/ov_SC06_011.c b/src/ov_SC06_011/ov_SC06_011.c index c3eed432f1..ccbfcc3249 100644 --- a/src/ov_SC06_011/ov_SC06_011.c +++ b/src/ov_SC06_011/ov_SC06_011.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_011/ov_SC06_011_after.c b/src/ov_SC06_011/ov_SC06_011_after.c index 3c5ff8c5b5..97b6b96f49 100644 --- a/src/ov_SC06_011/ov_SC06_011_after.c +++ b/src/ov_SC06_011/ov_SC06_011_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_011/ov_SC06_011_jr_8012ACE0.c b/src/ov_SC06_011/ov_SC06_011_jr_8012ACE0.c index 7706fb8dec..ac4ea7c926 100644 --- a/src/ov_SC06_011/ov_SC06_011_jr_8012ACE0.c +++ b/src/ov_SC06_011/ov_SC06_011_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_011/ov_SC06_011_jr_80135D20.c b/src/ov_SC06_011/ov_SC06_011_jr_80135D20.c index bab896adab..a243510b3e 100644 --- a/src/ov_SC06_011/ov_SC06_011_jr_80135D20.c +++ b/src/ov_SC06_011/ov_SC06_011_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_011/ov_SC06_011_jr_801380E0.c b/src/ov_SC06_011/ov_SC06_011_jr_801380E0.c index 468d4121d0..7f72a90ce1 100644 --- a/src/ov_SC06_011/ov_SC06_011_jr_801380E0.c +++ b/src/ov_SC06_011/ov_SC06_011_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 4df851c0e3..9591cc159b 100644 --- a/src/ov_SC06_011/ov_SC06_011_jr_8015AE2C.c +++ b/src/ov_SC06_011/ov_SC06_011_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_011/ov_SC06_011_jr_8015C32C.c b/src/ov_SC06_011/ov_SC06_011_jr_8015C32C.c index 195aa3b195..6bdd151f0d 100644 --- a/src/ov_SC06_011/ov_SC06_011_jr_8015C32C.c +++ b/src/ov_SC06_011/ov_SC06_011_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_011/ov_SC06_011_jr_8016AB6C.c b/src/ov_SC06_011/ov_SC06_011_jr_8016AB6C.c index eec6b153a0..7327fbbf29 100644 --- a/src/ov_SC06_011/ov_SC06_011_jr_8016AB6C.c +++ b/src/ov_SC06_011/ov_SC06_011_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_011/ov_SC06_011_jr_80171B4C.c b/src/ov_SC06_011/ov_SC06_011_jr_80171B4C.c index 9df52bbacc..8d0d48a3ea 100644 --- a/src/ov_SC06_011/ov_SC06_011_jr_80171B4C.c +++ b/src/ov_SC06_011/ov_SC06_011_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_011/ov_SC06_011_jr_801734BC.c b/src/ov_SC06_011/ov_SC06_011_jr_801734BC.c index 00ec83de52..d993f52b1c 100644 --- a/src/ov_SC06_011/ov_SC06_011_jr_801734BC.c +++ b/src/ov_SC06_011/ov_SC06_011_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_011/ov_SC06_011_o0c.c b/src/ov_SC06_011/ov_SC06_011_o0c.c index 4fa89e1099..9e15322079 100644 --- a/src/ov_SC06_011/ov_SC06_011_o0c.c +++ b/src/ov_SC06_011/ov_SC06_011_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_013/ov_SC06_013.c b/src/ov_SC06_013/ov_SC06_013.c index b5d72d1400..286dda7524 100644 --- a/src/ov_SC06_013/ov_SC06_013.c +++ b/src/ov_SC06_013/ov_SC06_013.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_013/ov_SC06_013_after.c b/src/ov_SC06_013/ov_SC06_013_after.c index 7d93b97aa4..fc9b4e0d32 100644 --- a/src/ov_SC06_013/ov_SC06_013_after.c +++ b/src/ov_SC06_013/ov_SC06_013_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_013/ov_SC06_013_jr_8012ACE0.c b/src/ov_SC06_013/ov_SC06_013_jr_8012ACE0.c index 72150a3be9..71fe490bdf 100644 --- a/src/ov_SC06_013/ov_SC06_013_jr_8012ACE0.c +++ b/src/ov_SC06_013/ov_SC06_013_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_013/ov_SC06_013_jr_80135D20.c b/src/ov_SC06_013/ov_SC06_013_jr_80135D20.c index bb824f5d15..2b1762833c 100644 --- a/src/ov_SC06_013/ov_SC06_013_jr_80135D20.c +++ b/src/ov_SC06_013/ov_SC06_013_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_013/ov_SC06_013_jr_801380E0.c b/src/ov_SC06_013/ov_SC06_013_jr_801380E0.c index 9c01bf1a41..13e3d0f57c 100644 --- a/src/ov_SC06_013/ov_SC06_013_jr_801380E0.c +++ b/src/ov_SC06_013/ov_SC06_013_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 1d28ec8aed..932b4295ba 100644 --- a/src/ov_SC06_013/ov_SC06_013_jr_8015AE2C.c +++ b/src/ov_SC06_013/ov_SC06_013_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_013/ov_SC06_013_jr_8015C32C.c b/src/ov_SC06_013/ov_SC06_013_jr_8015C32C.c index 53c127f762..92954033ff 100644 --- a/src/ov_SC06_013/ov_SC06_013_jr_8015C32C.c +++ b/src/ov_SC06_013/ov_SC06_013_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_013/ov_SC06_013_jr_8016AB6C.c b/src/ov_SC06_013/ov_SC06_013_jr_8016AB6C.c index c8a0e5f5fa..fc7647531f 100644 --- a/src/ov_SC06_013/ov_SC06_013_jr_8016AB6C.c +++ b/src/ov_SC06_013/ov_SC06_013_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_013/ov_SC06_013_jr_80171B4C.c b/src/ov_SC06_013/ov_SC06_013_jr_80171B4C.c index 114ea8e285..12f5edad8c 100644 --- a/src/ov_SC06_013/ov_SC06_013_jr_80171B4C.c +++ b/src/ov_SC06_013/ov_SC06_013_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_013/ov_SC06_013_jr_801734BC.c b/src/ov_SC06_013/ov_SC06_013_jr_801734BC.c index 10ac84e88b..53fb1d1c7a 100644 --- a/src/ov_SC06_013/ov_SC06_013_jr_801734BC.c +++ b/src/ov_SC06_013/ov_SC06_013_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_013/ov_SC06_013_o0c.c b/src/ov_SC06_013/ov_SC06_013_o0c.c index 26bf3809ac..1be8346244 100644 --- a/src/ov_SC06_013/ov_SC06_013_o0c.c +++ b/src/ov_SC06_013/ov_SC06_013_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_014/ov_SC06_014.c b/src/ov_SC06_014/ov_SC06_014.c index ad6d3d24e9..466f5de6e8 100644 --- a/src/ov_SC06_014/ov_SC06_014.c +++ b/src/ov_SC06_014/ov_SC06_014.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_014/ov_SC06_014_after.c b/src/ov_SC06_014/ov_SC06_014_after.c index 89502640a0..6631b41115 100644 --- a/src/ov_SC06_014/ov_SC06_014_after.c +++ b/src/ov_SC06_014/ov_SC06_014_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_014/ov_SC06_014_jr_8012ACE0.c b/src/ov_SC06_014/ov_SC06_014_jr_8012ACE0.c index 814a114567..d40a49da12 100644 --- a/src/ov_SC06_014/ov_SC06_014_jr_8012ACE0.c +++ b/src/ov_SC06_014/ov_SC06_014_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_014/ov_SC06_014_jr_80135D20.c b/src/ov_SC06_014/ov_SC06_014_jr_80135D20.c index b3027c14f6..7bea12ca29 100644 --- a/src/ov_SC06_014/ov_SC06_014_jr_80135D20.c +++ b/src/ov_SC06_014/ov_SC06_014_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_014/ov_SC06_014_jr_801380E0.c b/src/ov_SC06_014/ov_SC06_014_jr_801380E0.c index eeb15c70eb..d330a255fc 100644 --- a/src/ov_SC06_014/ov_SC06_014_jr_801380E0.c +++ b/src/ov_SC06_014/ov_SC06_014_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 93c743f0a1..970fdb67d1 100644 --- a/src/ov_SC06_014/ov_SC06_014_jr_8015AE2C.c +++ b/src/ov_SC06_014/ov_SC06_014_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_014/ov_SC06_014_jr_8015C32C.c b/src/ov_SC06_014/ov_SC06_014_jr_8015C32C.c index 02d1142dac..21e2e5ea40 100644 --- a/src/ov_SC06_014/ov_SC06_014_jr_8015C32C.c +++ b/src/ov_SC06_014/ov_SC06_014_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_014/ov_SC06_014_jr_8016AB6C.c b/src/ov_SC06_014/ov_SC06_014_jr_8016AB6C.c index c354a67cda..b139b2a89f 100644 --- a/src/ov_SC06_014/ov_SC06_014_jr_8016AB6C.c +++ b/src/ov_SC06_014/ov_SC06_014_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_014/ov_SC06_014_jr_80171B4C.c b/src/ov_SC06_014/ov_SC06_014_jr_80171B4C.c index 131de90d9d..7218f195a5 100644 --- a/src/ov_SC06_014/ov_SC06_014_jr_80171B4C.c +++ b/src/ov_SC06_014/ov_SC06_014_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_014/ov_SC06_014_jr_801734BC.c b/src/ov_SC06_014/ov_SC06_014_jr_801734BC.c index dec4393737..5b59b38cef 100644 --- a/src/ov_SC06_014/ov_SC06_014_jr_801734BC.c +++ b/src/ov_SC06_014/ov_SC06_014_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_014/ov_SC06_014_o0c.c b/src/ov_SC06_014/ov_SC06_014_o0c.c index 2b79f2076e..689a827992 100644 --- a/src/ov_SC06_014/ov_SC06_014_o0c.c +++ b/src/ov_SC06_014/ov_SC06_014_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_015/ov_SC06_015.c b/src/ov_SC06_015/ov_SC06_015.c index 639a8237dd..f25d298c67 100644 --- a/src/ov_SC06_015/ov_SC06_015.c +++ b/src/ov_SC06_015/ov_SC06_015.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_015/ov_SC06_015_after.c b/src/ov_SC06_015/ov_SC06_015_after.c index b2661a500e..e168dbc1be 100644 --- a/src/ov_SC06_015/ov_SC06_015_after.c +++ b/src/ov_SC06_015/ov_SC06_015_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_015/ov_SC06_015_jr_8012ACE0.c b/src/ov_SC06_015/ov_SC06_015_jr_8012ACE0.c index 0801191d4d..dbabc0f364 100644 --- a/src/ov_SC06_015/ov_SC06_015_jr_8012ACE0.c +++ b/src/ov_SC06_015/ov_SC06_015_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_015/ov_SC06_015_jr_80135D20.c b/src/ov_SC06_015/ov_SC06_015_jr_80135D20.c index fc595ebc0a..72fe7fc9b7 100644 --- a/src/ov_SC06_015/ov_SC06_015_jr_80135D20.c +++ b/src/ov_SC06_015/ov_SC06_015_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_015/ov_SC06_015_jr_801380E0.c b/src/ov_SC06_015/ov_SC06_015_jr_801380E0.c index c7695a9df6..a9e946042e 100644 --- a/src/ov_SC06_015/ov_SC06_015_jr_801380E0.c +++ b/src/ov_SC06_015/ov_SC06_015_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 33af1d107f..c4fc7ce3c3 100644 --- a/src/ov_SC06_015/ov_SC06_015_jr_8015AE2C.c +++ b/src/ov_SC06_015/ov_SC06_015_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_015/ov_SC06_015_jr_8015C32C.c b/src/ov_SC06_015/ov_SC06_015_jr_8015C32C.c index 5f42c4778c..06942efaec 100644 --- a/src/ov_SC06_015/ov_SC06_015_jr_8015C32C.c +++ b/src/ov_SC06_015/ov_SC06_015_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_015/ov_SC06_015_jr_8016AB6C.c b/src/ov_SC06_015/ov_SC06_015_jr_8016AB6C.c index 4b0c2897c0..c7d3decfc4 100644 --- a/src/ov_SC06_015/ov_SC06_015_jr_8016AB6C.c +++ b/src/ov_SC06_015/ov_SC06_015_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_015/ov_SC06_015_jr_80171B4C.c b/src/ov_SC06_015/ov_SC06_015_jr_80171B4C.c index 8ad4dc939c..71a0a74966 100644 --- a/src/ov_SC06_015/ov_SC06_015_jr_80171B4C.c +++ b/src/ov_SC06_015/ov_SC06_015_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_015/ov_SC06_015_jr_801734BC.c b/src/ov_SC06_015/ov_SC06_015_jr_801734BC.c index ec91f27a10..8601b2fa4a 100644 --- a/src/ov_SC06_015/ov_SC06_015_jr_801734BC.c +++ b/src/ov_SC06_015/ov_SC06_015_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_015/ov_SC06_015_o0c.c b/src/ov_SC06_015/ov_SC06_015_o0c.c index aa8e91e941..e4d299fd1f 100644 --- a/src/ov_SC06_015/ov_SC06_015_o0c.c +++ b/src/ov_SC06_015/ov_SC06_015_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_016/ov_SC06_016.c b/src/ov_SC06_016/ov_SC06_016.c index b64ef7483b..574bbfae32 100644 --- a/src/ov_SC06_016/ov_SC06_016.c +++ b/src/ov_SC06_016/ov_SC06_016.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_016/ov_SC06_016_after.c b/src/ov_SC06_016/ov_SC06_016_after.c index 5cca591c37..daceb2cd8a 100644 --- a/src/ov_SC06_016/ov_SC06_016_after.c +++ b/src/ov_SC06_016/ov_SC06_016_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_016/ov_SC06_016_jr_8012ACE0.c b/src/ov_SC06_016/ov_SC06_016_jr_8012ACE0.c index 659cdc7dec..558f270b19 100644 --- a/src/ov_SC06_016/ov_SC06_016_jr_8012ACE0.c +++ b/src/ov_SC06_016/ov_SC06_016_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_016/ov_SC06_016_jr_80135D20.c b/src/ov_SC06_016/ov_SC06_016_jr_80135D20.c index 472ea5d6a6..4dd08fb391 100644 --- a/src/ov_SC06_016/ov_SC06_016_jr_80135D20.c +++ b/src/ov_SC06_016/ov_SC06_016_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_016/ov_SC06_016_jr_801380E0.c b/src/ov_SC06_016/ov_SC06_016_jr_801380E0.c index d8aa969ab8..d0e6fdae4e 100644 --- a/src/ov_SC06_016/ov_SC06_016_jr_801380E0.c +++ b/src/ov_SC06_016/ov_SC06_016_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ 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 e2c752ef65..b2987f9ec7 100644 --- a/src/ov_SC06_016/ov_SC06_016_jr_8015AE2C.c +++ b/src/ov_SC06_016/ov_SC06_016_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_016/ov_SC06_016_jr_8015C32C.c b/src/ov_SC06_016/ov_SC06_016_jr_8015C32C.c index 2814264d3d..48bd089cd4 100644 --- a/src/ov_SC06_016/ov_SC06_016_jr_8015C32C.c +++ b/src/ov_SC06_016/ov_SC06_016_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_016/ov_SC06_016_jr_8016AB6C.c b/src/ov_SC06_016/ov_SC06_016_jr_8016AB6C.c index 9a6b9db38e..7948e9f3a3 100644 --- a/src/ov_SC06_016/ov_SC06_016_jr_8016AB6C.c +++ b/src/ov_SC06_016/ov_SC06_016_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_016/ov_SC06_016_jr_80171B4C.c b/src/ov_SC06_016/ov_SC06_016_jr_80171B4C.c index da1c7ccdfc..00b0cb2c8c 100644 --- a/src/ov_SC06_016/ov_SC06_016_jr_80171B4C.c +++ b/src/ov_SC06_016/ov_SC06_016_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_016/ov_SC06_016_jr_801734BC.c b/src/ov_SC06_016/ov_SC06_016_jr_801734BC.c index 019e6126c8..64a903a26c 100644 --- a/src/ov_SC06_016/ov_SC06_016_jr_801734BC.c +++ b/src/ov_SC06_016/ov_SC06_016_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_016/ov_SC06_016_o0c.c b/src/ov_SC06_016/ov_SC06_016_o0c.c index d9b2d4add1..78bda282f6 100644 --- a/src/ov_SC06_016/ov_SC06_016_o0c.c +++ b/src/ov_SC06_016/ov_SC06_016_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_018/ov_SC06_018.c b/src/ov_SC06_018/ov_SC06_018.c index 23947687d4..e5bf03361b 100644 --- a/src/ov_SC06_018/ov_SC06_018.c +++ b/src/ov_SC06_018/ov_SC06_018.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_018/ov_SC06_018_after.c b/src/ov_SC06_018/ov_SC06_018_after.c index 35ac0e89f3..4e6b3b9219 100644 --- a/src/ov_SC06_018/ov_SC06_018_after.c +++ b/src/ov_SC06_018/ov_SC06_018_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_018/ov_SC06_018_jr_8012ACE0.c b/src/ov_SC06_018/ov_SC06_018_jr_8012ACE0.c index d1c678778a..6068cd342d 100644 --- a/src/ov_SC06_018/ov_SC06_018_jr_8012ACE0.c +++ b/src/ov_SC06_018/ov_SC06_018_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_018/ov_SC06_018_jr_80135D20.c b/src/ov_SC06_018/ov_SC06_018_jr_80135D20.c index 34ac8ae1ee..e3a4976d26 100644 --- a/src/ov_SC06_018/ov_SC06_018_jr_80135D20.c +++ b/src/ov_SC06_018/ov_SC06_018_jr_80135D20.c @@ -1496,17 +1496,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1550,32 +1540,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_018/ov_SC06_018_jr_801380E0.c b/src/ov_SC06_018/ov_SC06_018_jr_801380E0.c index 5dbd7adfc1..883b2888e6 100644 --- a/src/ov_SC06_018/ov_SC06_018_jr_801380E0.c +++ b/src/ov_SC06_018/ov_SC06_018_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC06_018/ov_SC06_018_jr_8015AE2C.c b/src/ov_SC06_018/ov_SC06_018_jr_8015AE2C.c index a119c95057..2f884b73a9 100644 --- a/src/ov_SC06_018/ov_SC06_018_jr_8015AE2C.c +++ b/src/ov_SC06_018/ov_SC06_018_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_018/ov_SC06_018_jr_8015C32C.c b/src/ov_SC06_018/ov_SC06_018_jr_8015C32C.c index 25ab2be7a8..cf7578a293 100644 --- a/src/ov_SC06_018/ov_SC06_018_jr_8015C32C.c +++ b/src/ov_SC06_018/ov_SC06_018_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_018/ov_SC06_018_jr_8016AB6C.c b/src/ov_SC06_018/ov_SC06_018_jr_8016AB6C.c index 781e40078f..8c4f82e40a 100644 --- a/src/ov_SC06_018/ov_SC06_018_jr_8016AB6C.c +++ b/src/ov_SC06_018/ov_SC06_018_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_018/ov_SC06_018_jr_80171B4C.c b/src/ov_SC06_018/ov_SC06_018_jr_80171B4C.c index ce3004241a..68365b5498 100644 --- a/src/ov_SC06_018/ov_SC06_018_jr_80171B4C.c +++ b/src/ov_SC06_018/ov_SC06_018_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_018/ov_SC06_018_jr_801734BC.c b/src/ov_SC06_018/ov_SC06_018_jr_801734BC.c index fa110fab5f..2f28063375 100644 --- a/src/ov_SC06_018/ov_SC06_018_jr_801734BC.c +++ b/src/ov_SC06_018/ov_SC06_018_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2921,38 +2888,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2962,44 +2898,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3790,41 +3689,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_018/ov_SC06_018_o0c.c b/src/ov_SC06_018/ov_SC06_018_o0c.c index 1397a1c041..5cb0623573 100644 --- a/src/ov_SC06_018/ov_SC06_018_o0c.c +++ b/src/ov_SC06_018/ov_SC06_018_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_020/ov_SC06_020.c b/src/ov_SC06_020/ov_SC06_020.c index 93f383c115..31d5e4febc 100644 --- a/src/ov_SC06_020/ov_SC06_020.c +++ b/src/ov_SC06_020/ov_SC06_020.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_020/ov_SC06_020_after.c b/src/ov_SC06_020/ov_SC06_020_after.c index f539b3c64b..088dc27f89 100644 --- a/src/ov_SC06_020/ov_SC06_020_after.c +++ b/src/ov_SC06_020/ov_SC06_020_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_020/ov_SC06_020_jr_8012ACE0.c b/src/ov_SC06_020/ov_SC06_020_jr_8012ACE0.c index dac7d9d906..5d88fc197e 100644 --- a/src/ov_SC06_020/ov_SC06_020_jr_8012ACE0.c +++ b/src/ov_SC06_020/ov_SC06_020_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_020/ov_SC06_020_jr_80135D20.c b/src/ov_SC06_020/ov_SC06_020_jr_80135D20.c index e16d943cbe..eafeab8a0e 100644 --- a/src/ov_SC06_020/ov_SC06_020_jr_80135D20.c +++ b/src/ov_SC06_020/ov_SC06_020_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_020/ov_SC06_020_jr_801380E0.c b/src/ov_SC06_020/ov_SC06_020_jr_801380E0.c index 91e08ae076..4990c4275d 100644 --- a/src/ov_SC06_020/ov_SC06_020_jr_801380E0.c +++ b/src/ov_SC06_020/ov_SC06_020_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC06_020/ov_SC06_020_jr_8015AE2C.c b/src/ov_SC06_020/ov_SC06_020_jr_8015AE2C.c index 10bbe5c10e..2cd380d167 100644 --- a/src/ov_SC06_020/ov_SC06_020_jr_8015AE2C.c +++ b/src/ov_SC06_020/ov_SC06_020_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_020/ov_SC06_020_jr_8015C32C.c b/src/ov_SC06_020/ov_SC06_020_jr_8015C32C.c index 25fcf9c9e8..c437b95735 100644 --- a/src/ov_SC06_020/ov_SC06_020_jr_8015C32C.c +++ b/src/ov_SC06_020/ov_SC06_020_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_020/ov_SC06_020_jr_8016AB6C.c b/src/ov_SC06_020/ov_SC06_020_jr_8016AB6C.c index 5ed8f93bed..9954c0f55c 100644 --- a/src/ov_SC06_020/ov_SC06_020_jr_8016AB6C.c +++ b/src/ov_SC06_020/ov_SC06_020_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_020/ov_SC06_020_jr_80171B4C.c b/src/ov_SC06_020/ov_SC06_020_jr_80171B4C.c index ab85fcd879..db13f761cb 100644 --- a/src/ov_SC06_020/ov_SC06_020_jr_80171B4C.c +++ b/src/ov_SC06_020/ov_SC06_020_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_020/ov_SC06_020_jr_801734BC.c b/src/ov_SC06_020/ov_SC06_020_jr_801734BC.c index 30b94c6fae..b83e64ffd5 100644 --- a/src/ov_SC06_020/ov_SC06_020_jr_801734BC.c +++ b/src/ov_SC06_020/ov_SC06_020_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_020/ov_SC06_020_o0c.c b/src/ov_SC06_020/ov_SC06_020_o0c.c index 7fc20bdfdb..dd765e3ba5 100644 --- a/src/ov_SC06_020/ov_SC06_020_o0c.c +++ b/src/ov_SC06_020/ov_SC06_020_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_022/ov_SC06_022.c b/src/ov_SC06_022/ov_SC06_022.c index 2ca5400bd1..cf76eb370f 100644 --- a/src/ov_SC06_022/ov_SC06_022.c +++ b/src/ov_SC06_022/ov_SC06_022.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_022/ov_SC06_022_after.c b/src/ov_SC06_022/ov_SC06_022_after.c index 826eced677..8901eedf8f 100644 --- a/src/ov_SC06_022/ov_SC06_022_after.c +++ b/src/ov_SC06_022/ov_SC06_022_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_022/ov_SC06_022_jr_8012ACE0.c b/src/ov_SC06_022/ov_SC06_022_jr_8012ACE0.c index 86f0f77553..256371f941 100644 --- a/src/ov_SC06_022/ov_SC06_022_jr_8012ACE0.c +++ b/src/ov_SC06_022/ov_SC06_022_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_022/ov_SC06_022_jr_80135D20.c b/src/ov_SC06_022/ov_SC06_022_jr_80135D20.c index 4a1e873961..37c5124763 100644 --- a/src/ov_SC06_022/ov_SC06_022_jr_80135D20.c +++ b/src/ov_SC06_022/ov_SC06_022_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_022/ov_SC06_022_jr_801380E0.c b/src/ov_SC06_022/ov_SC06_022_jr_801380E0.c index 3df56e470c..b93244030c 100644 --- a/src/ov_SC06_022/ov_SC06_022_jr_801380E0.c +++ b/src/ov_SC06_022/ov_SC06_022_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC06_022/ov_SC06_022_jr_8015AE2C.c b/src/ov_SC06_022/ov_SC06_022_jr_8015AE2C.c index b405797748..81798f8b1a 100644 --- a/src/ov_SC06_022/ov_SC06_022_jr_8015AE2C.c +++ b/src/ov_SC06_022/ov_SC06_022_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_022/ov_SC06_022_jr_8015C32C.c b/src/ov_SC06_022/ov_SC06_022_jr_8015C32C.c index dde1ed74ef..7b5523b358 100644 --- a/src/ov_SC06_022/ov_SC06_022_jr_8015C32C.c +++ b/src/ov_SC06_022/ov_SC06_022_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_022/ov_SC06_022_jr_8016AB6C.c b/src/ov_SC06_022/ov_SC06_022_jr_8016AB6C.c index 295d8d41ff..013fadde70 100644 --- a/src/ov_SC06_022/ov_SC06_022_jr_8016AB6C.c +++ b/src/ov_SC06_022/ov_SC06_022_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_022/ov_SC06_022_jr_80171B4C.c b/src/ov_SC06_022/ov_SC06_022_jr_80171B4C.c index 8f153632f9..ef8a8b8a37 100644 --- a/src/ov_SC06_022/ov_SC06_022_jr_80171B4C.c +++ b/src/ov_SC06_022/ov_SC06_022_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_022/ov_SC06_022_jr_801734BC.c b/src/ov_SC06_022/ov_SC06_022_jr_801734BC.c index c4ee59cc13..833e4bf59e 100644 --- a/src/ov_SC06_022/ov_SC06_022_jr_801734BC.c +++ b/src/ov_SC06_022/ov_SC06_022_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_022/ov_SC06_022_o0c.c b/src/ov_SC06_022/ov_SC06_022_o0c.c index e71d8152e3..1f6ec14113 100644 --- a/src/ov_SC06_022/ov_SC06_022_o0c.c +++ b/src/ov_SC06_022/ov_SC06_022_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_024/ov_SC06_024.c b/src/ov_SC06_024/ov_SC06_024.c index b0f9370378..9036fa77bd 100644 --- a/src/ov_SC06_024/ov_SC06_024.c +++ b/src/ov_SC06_024/ov_SC06_024.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_024/ov_SC06_024_after.c b/src/ov_SC06_024/ov_SC06_024_after.c index 83c2629f4a..97bf829d02 100644 --- a/src/ov_SC06_024/ov_SC06_024_after.c +++ b/src/ov_SC06_024/ov_SC06_024_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_024/ov_SC06_024_jr_8012ACE0.c b/src/ov_SC06_024/ov_SC06_024_jr_8012ACE0.c index b3b2da4d0c..acd16f18a0 100644 --- a/src/ov_SC06_024/ov_SC06_024_jr_8012ACE0.c +++ b/src/ov_SC06_024/ov_SC06_024_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_024/ov_SC06_024_jr_80135D20.c b/src/ov_SC06_024/ov_SC06_024_jr_80135D20.c index 584be056e7..90f8dcc35b 100644 --- a/src/ov_SC06_024/ov_SC06_024_jr_80135D20.c +++ b/src/ov_SC06_024/ov_SC06_024_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_024/ov_SC06_024_jr_801380E0.c b/src/ov_SC06_024/ov_SC06_024_jr_801380E0.c index 02d657761d..a2ccd4f6a1 100644 --- a/src/ov_SC06_024/ov_SC06_024_jr_801380E0.c +++ b/src/ov_SC06_024/ov_SC06_024_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC06_024/ov_SC06_024_jr_8015AE2C.c b/src/ov_SC06_024/ov_SC06_024_jr_8015AE2C.c index 22c8e588c9..b822dfcd0d 100644 --- a/src/ov_SC06_024/ov_SC06_024_jr_8015AE2C.c +++ b/src/ov_SC06_024/ov_SC06_024_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_024/ov_SC06_024_jr_8015C32C.c b/src/ov_SC06_024/ov_SC06_024_jr_8015C32C.c index 2919002429..92c0c5529c 100644 --- a/src/ov_SC06_024/ov_SC06_024_jr_8015C32C.c +++ b/src/ov_SC06_024/ov_SC06_024_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_024/ov_SC06_024_jr_8016AB6C.c b/src/ov_SC06_024/ov_SC06_024_jr_8016AB6C.c index 1c13697299..9e3cc417f4 100644 --- a/src/ov_SC06_024/ov_SC06_024_jr_8016AB6C.c +++ b/src/ov_SC06_024/ov_SC06_024_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_024/ov_SC06_024_jr_80171B4C.c b/src/ov_SC06_024/ov_SC06_024_jr_80171B4C.c index cfc6f2366a..e5b4c8a388 100644 --- a/src/ov_SC06_024/ov_SC06_024_jr_80171B4C.c +++ b/src/ov_SC06_024/ov_SC06_024_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_024/ov_SC06_024_jr_801734BC.c b/src/ov_SC06_024/ov_SC06_024_jr_801734BC.c index bc2d77340e..ddb07fe47a 100644 --- a/src/ov_SC06_024/ov_SC06_024_jr_801734BC.c +++ b/src/ov_SC06_024/ov_SC06_024_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_024/ov_SC06_024_o0c.c b/src/ov_SC06_024/ov_SC06_024_o0c.c index 6843fbbeb1..56aca3df72 100644 --- a/src/ov_SC06_024/ov_SC06_024_o0c.c +++ b/src/ov_SC06_024/ov_SC06_024_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_025/ov_SC06_025.c b/src/ov_SC06_025/ov_SC06_025.c index 0e6f579b8e..f8bf9e8788 100644 --- a/src/ov_SC06_025/ov_SC06_025.c +++ b/src/ov_SC06_025/ov_SC06_025.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_025/ov_SC06_025_after.c b/src/ov_SC06_025/ov_SC06_025_after.c index aba9a55e7a..b81bda3be3 100644 --- a/src/ov_SC06_025/ov_SC06_025_after.c +++ b/src/ov_SC06_025/ov_SC06_025_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_025/ov_SC06_025_jr_8012ACE0.c b/src/ov_SC06_025/ov_SC06_025_jr_8012ACE0.c index 7fb2f7344d..050fddba37 100644 --- a/src/ov_SC06_025/ov_SC06_025_jr_8012ACE0.c +++ b/src/ov_SC06_025/ov_SC06_025_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_025/ov_SC06_025_jr_80135D20.c b/src/ov_SC06_025/ov_SC06_025_jr_80135D20.c index 124520ddb8..983d23c135 100644 --- a/src/ov_SC06_025/ov_SC06_025_jr_80135D20.c +++ b/src/ov_SC06_025/ov_SC06_025_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_025/ov_SC06_025_jr_801380E0.c b/src/ov_SC06_025/ov_SC06_025_jr_801380E0.c index 326db76e1a..a662cf4c94 100644 --- a/src/ov_SC06_025/ov_SC06_025_jr_801380E0.c +++ b/src/ov_SC06_025/ov_SC06_025_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC06_025/ov_SC06_025_jr_8015AE2C.c b/src/ov_SC06_025/ov_SC06_025_jr_8015AE2C.c index 918d8efb14..be48b57f57 100644 --- a/src/ov_SC06_025/ov_SC06_025_jr_8015AE2C.c +++ b/src/ov_SC06_025/ov_SC06_025_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_025/ov_SC06_025_jr_8015C32C.c b/src/ov_SC06_025/ov_SC06_025_jr_8015C32C.c index 3971c93f89..7a662e2a8d 100644 --- a/src/ov_SC06_025/ov_SC06_025_jr_8015C32C.c +++ b/src/ov_SC06_025/ov_SC06_025_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_025/ov_SC06_025_jr_8016AB6C.c b/src/ov_SC06_025/ov_SC06_025_jr_8016AB6C.c index d7e2b23f83..3f044c3501 100644 --- a/src/ov_SC06_025/ov_SC06_025_jr_8016AB6C.c +++ b/src/ov_SC06_025/ov_SC06_025_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_025/ov_SC06_025_jr_80171B4C.c b/src/ov_SC06_025/ov_SC06_025_jr_80171B4C.c index 1c4afc75a5..597e139c84 100644 --- a/src/ov_SC06_025/ov_SC06_025_jr_80171B4C.c +++ b/src/ov_SC06_025/ov_SC06_025_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_025/ov_SC06_025_jr_801734BC.c b/src/ov_SC06_025/ov_SC06_025_jr_801734BC.c index 2a6be263a7..508ec70381 100644 --- a/src/ov_SC06_025/ov_SC06_025_jr_801734BC.c +++ b/src/ov_SC06_025/ov_SC06_025_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_025/ov_SC06_025_o0c.c b/src/ov_SC06_025/ov_SC06_025_o0c.c index 05a2e69970..7a4cdae3dc 100644 --- a/src/ov_SC06_025/ov_SC06_025_o0c.c +++ b/src/ov_SC06_025/ov_SC06_025_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_027/ov_SC06_027.c b/src/ov_SC06_027/ov_SC06_027.c index 8789aea654..268f982f55 100644 --- a/src/ov_SC06_027/ov_SC06_027.c +++ b/src/ov_SC06_027/ov_SC06_027.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_027/ov_SC06_027_after.c b/src/ov_SC06_027/ov_SC06_027_after.c index 524416abc6..c5fa05882e 100644 --- a/src/ov_SC06_027/ov_SC06_027_after.c +++ b/src/ov_SC06_027/ov_SC06_027_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_027/ov_SC06_027_jr_8012ACE0.c b/src/ov_SC06_027/ov_SC06_027_jr_8012ACE0.c index a961152528..1fa2263c1b 100644 --- a/src/ov_SC06_027/ov_SC06_027_jr_8012ACE0.c +++ b/src/ov_SC06_027/ov_SC06_027_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_027/ov_SC06_027_jr_80135D20.c b/src/ov_SC06_027/ov_SC06_027_jr_80135D20.c index b97043d74c..4b7f5c3316 100644 --- a/src/ov_SC06_027/ov_SC06_027_jr_80135D20.c +++ b/src/ov_SC06_027/ov_SC06_027_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_027/ov_SC06_027_jr_801380E0.c b/src/ov_SC06_027/ov_SC06_027_jr_801380E0.c index 0e8d6038a8..4111dd1bc0 100644 --- a/src/ov_SC06_027/ov_SC06_027_jr_801380E0.c +++ b/src/ov_SC06_027/ov_SC06_027_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC06_027/ov_SC06_027_jr_8015AE2C.c b/src/ov_SC06_027/ov_SC06_027_jr_8015AE2C.c index 8e5d7e9689..6db2584bcf 100644 --- a/src/ov_SC06_027/ov_SC06_027_jr_8015AE2C.c +++ b/src/ov_SC06_027/ov_SC06_027_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_027/ov_SC06_027_jr_8015C32C.c b/src/ov_SC06_027/ov_SC06_027_jr_8015C32C.c index 1aaab734f5..d1d9726241 100644 --- a/src/ov_SC06_027/ov_SC06_027_jr_8015C32C.c +++ b/src/ov_SC06_027/ov_SC06_027_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_027/ov_SC06_027_jr_8016AB6C.c b/src/ov_SC06_027/ov_SC06_027_jr_8016AB6C.c index ab7d4f42cd..f6aae51274 100644 --- a/src/ov_SC06_027/ov_SC06_027_jr_8016AB6C.c +++ b/src/ov_SC06_027/ov_SC06_027_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_027/ov_SC06_027_jr_80171B4C.c b/src/ov_SC06_027/ov_SC06_027_jr_80171B4C.c index f9ca893117..44cc658a57 100644 --- a/src/ov_SC06_027/ov_SC06_027_jr_80171B4C.c +++ b/src/ov_SC06_027/ov_SC06_027_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_027/ov_SC06_027_jr_801734BC.c b/src/ov_SC06_027/ov_SC06_027_jr_801734BC.c index 40c98d10f4..f36a66d25f 100644 --- a/src/ov_SC06_027/ov_SC06_027_jr_801734BC.c +++ b/src/ov_SC06_027/ov_SC06_027_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_027/ov_SC06_027_o0c.c b/src/ov_SC06_027/ov_SC06_027_o0c.c index 5e1135e852..7247cf6e5f 100644 --- a/src/ov_SC06_027/ov_SC06_027_o0c.c +++ b/src/ov_SC06_027/ov_SC06_027_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_029/ov_SC06_029.c b/src/ov_SC06_029/ov_SC06_029.c index c41843e6c3..7fee92dc0a 100644 --- a/src/ov_SC06_029/ov_SC06_029.c +++ b/src/ov_SC06_029/ov_SC06_029.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_029/ov_SC06_029_after.c b/src/ov_SC06_029/ov_SC06_029_after.c index 4c676b9622..ca57449b9b 100644 --- a/src/ov_SC06_029/ov_SC06_029_after.c +++ b/src/ov_SC06_029/ov_SC06_029_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_029/ov_SC06_029_jr_8012ACE0.c b/src/ov_SC06_029/ov_SC06_029_jr_8012ACE0.c index 8094d46a66..2f29dcfe71 100644 --- a/src/ov_SC06_029/ov_SC06_029_jr_8012ACE0.c +++ b/src/ov_SC06_029/ov_SC06_029_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_029/ov_SC06_029_jr_80135D20.c b/src/ov_SC06_029/ov_SC06_029_jr_80135D20.c index 48c1ab94fb..702b3f993a 100644 --- a/src/ov_SC06_029/ov_SC06_029_jr_80135D20.c +++ b/src/ov_SC06_029/ov_SC06_029_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_029/ov_SC06_029_jr_801380E0.c b/src/ov_SC06_029/ov_SC06_029_jr_801380E0.c index 699ef389d5..c7a712215a 100644 --- a/src/ov_SC06_029/ov_SC06_029_jr_801380E0.c +++ b/src/ov_SC06_029/ov_SC06_029_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC06_029/ov_SC06_029_jr_8015AE2C.c b/src/ov_SC06_029/ov_SC06_029_jr_8015AE2C.c index 30896df339..7502ee72a1 100644 --- a/src/ov_SC06_029/ov_SC06_029_jr_8015AE2C.c +++ b/src/ov_SC06_029/ov_SC06_029_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_029/ov_SC06_029_jr_8015C32C.c b/src/ov_SC06_029/ov_SC06_029_jr_8015C32C.c index 6ef7f644c6..1a2493d1af 100644 --- a/src/ov_SC06_029/ov_SC06_029_jr_8015C32C.c +++ b/src/ov_SC06_029/ov_SC06_029_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_029/ov_SC06_029_jr_8016AB6C.c b/src/ov_SC06_029/ov_SC06_029_jr_8016AB6C.c index 646aee2c77..995b264ba2 100644 --- a/src/ov_SC06_029/ov_SC06_029_jr_8016AB6C.c +++ b/src/ov_SC06_029/ov_SC06_029_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_029/ov_SC06_029_jr_80171B4C.c b/src/ov_SC06_029/ov_SC06_029_jr_80171B4C.c index 5563addb8c..4e3cad087b 100644 --- a/src/ov_SC06_029/ov_SC06_029_jr_80171B4C.c +++ b/src/ov_SC06_029/ov_SC06_029_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_029/ov_SC06_029_jr_801734BC.c b/src/ov_SC06_029/ov_SC06_029_jr_801734BC.c index 68be5e6be2..156c98e2c3 100644 --- a/src/ov_SC06_029/ov_SC06_029_jr_801734BC.c +++ b/src/ov_SC06_029/ov_SC06_029_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_029/ov_SC06_029_o0c.c b/src/ov_SC06_029/ov_SC06_029_o0c.c index 0438c12d3d..15c9fcf85a 100644 --- a/src/ov_SC06_029/ov_SC06_029_o0c.c +++ b/src/ov_SC06_029/ov_SC06_029_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_030/ov_SC06_030.c b/src/ov_SC06_030/ov_SC06_030.c index d34f80b007..f7ef03905b 100644 --- a/src/ov_SC06_030/ov_SC06_030.c +++ b/src/ov_SC06_030/ov_SC06_030.c @@ -661,14 +661,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -694,40 +687,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_030/ov_SC06_030_after.c b/src/ov_SC06_030/ov_SC06_030_after.c index ef8dd995ed..9987fd28be 100644 --- a/src/ov_SC06_030/ov_SC06_030_after.c +++ b/src/ov_SC06_030/ov_SC06_030_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_030/ov_SC06_030_jr_8012ACE0.c b/src/ov_SC06_030/ov_SC06_030_jr_8012ACE0.c index 4af8483341..6d26874596 100644 --- a/src/ov_SC06_030/ov_SC06_030_jr_8012ACE0.c +++ b/src/ov_SC06_030/ov_SC06_030_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_030/ov_SC06_030_jr_80135D20.c b/src/ov_SC06_030/ov_SC06_030_jr_80135D20.c index 59ee0d0f9d..fc37b761cd 100644 --- a/src/ov_SC06_030/ov_SC06_030_jr_80135D20.c +++ b/src/ov_SC06_030/ov_SC06_030_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_030/ov_SC06_030_jr_801380E0.c b/src/ov_SC06_030/ov_SC06_030_jr_801380E0.c index 7cd5bd3683..684a29fb8b 100644 --- a/src/ov_SC06_030/ov_SC06_030_jr_801380E0.c +++ b/src/ov_SC06_030/ov_SC06_030_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC06_030/ov_SC06_030_jr_8015AE2C.c b/src/ov_SC06_030/ov_SC06_030_jr_8015AE2C.c index 5d4f0c3203..b71ea72f21 100644 --- a/src/ov_SC06_030/ov_SC06_030_jr_8015AE2C.c +++ b/src/ov_SC06_030/ov_SC06_030_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_030/ov_SC06_030_jr_8015C32C.c b/src/ov_SC06_030/ov_SC06_030_jr_8015C32C.c index 776536e1c2..9f24771a3b 100644 --- a/src/ov_SC06_030/ov_SC06_030_jr_8015C32C.c +++ b/src/ov_SC06_030/ov_SC06_030_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_030/ov_SC06_030_jr_8016AB6C.c b/src/ov_SC06_030/ov_SC06_030_jr_8016AB6C.c index a11033dd85..9098f36bf9 100644 --- a/src/ov_SC06_030/ov_SC06_030_jr_8016AB6C.c +++ b/src/ov_SC06_030/ov_SC06_030_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_030/ov_SC06_030_jr_80171B4C.c b/src/ov_SC06_030/ov_SC06_030_jr_80171B4C.c index f3a102b2d8..c335453198 100644 --- a/src/ov_SC06_030/ov_SC06_030_jr_80171B4C.c +++ b/src/ov_SC06_030/ov_SC06_030_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_030/ov_SC06_030_jr_801734BC.c b/src/ov_SC06_030/ov_SC06_030_jr_801734BC.c index dba06006b7..6848739edc 100644 --- a/src/ov_SC06_030/ov_SC06_030_jr_801734BC.c +++ b/src/ov_SC06_030/ov_SC06_030_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_030/ov_SC06_030_o0c.c b/src/ov_SC06_030/ov_SC06_030_o0c.c index 0e75c4f340..f84788fd2d 100644 --- a/src/ov_SC06_030/ov_SC06_030_o0c.c +++ b/src/ov_SC06_030/ov_SC06_030_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_032/ov_SC06_032.c b/src/ov_SC06_032/ov_SC06_032.c index 69dbbe65b5..87ee23ee25 100644 --- a/src/ov_SC06_032/ov_SC06_032.c +++ b/src/ov_SC06_032/ov_SC06_032.c @@ -661,14 +661,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -694,40 +687,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_032/ov_SC06_032_after.c b/src/ov_SC06_032/ov_SC06_032_after.c index e8e8cbe1b5..4a40a9ff0d 100644 --- a/src/ov_SC06_032/ov_SC06_032_after.c +++ b/src/ov_SC06_032/ov_SC06_032_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_032/ov_SC06_032_jr_8012ACE0.c b/src/ov_SC06_032/ov_SC06_032_jr_8012ACE0.c index c1587dee1c..21c9bb72ec 100644 --- a/src/ov_SC06_032/ov_SC06_032_jr_8012ACE0.c +++ b/src/ov_SC06_032/ov_SC06_032_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_032/ov_SC06_032_jr_80135D20.c b/src/ov_SC06_032/ov_SC06_032_jr_80135D20.c index 96e9eb3027..b801176203 100644 --- a/src/ov_SC06_032/ov_SC06_032_jr_80135D20.c +++ b/src/ov_SC06_032/ov_SC06_032_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_032/ov_SC06_032_jr_801380E0.c b/src/ov_SC06_032/ov_SC06_032_jr_801380E0.c index a328ec441b..23ac527088 100644 --- a/src/ov_SC06_032/ov_SC06_032_jr_801380E0.c +++ b/src/ov_SC06_032/ov_SC06_032_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC06_032/ov_SC06_032_jr_8015AE2C.c b/src/ov_SC06_032/ov_SC06_032_jr_8015AE2C.c index af8030f7d5..ef2c27f170 100644 --- a/src/ov_SC06_032/ov_SC06_032_jr_8015AE2C.c +++ b/src/ov_SC06_032/ov_SC06_032_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_032/ov_SC06_032_jr_8015C32C.c b/src/ov_SC06_032/ov_SC06_032_jr_8015C32C.c index cf5228c9b0..3c0b64f197 100644 --- a/src/ov_SC06_032/ov_SC06_032_jr_8015C32C.c +++ b/src/ov_SC06_032/ov_SC06_032_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_032/ov_SC06_032_jr_8016AB6C.c b/src/ov_SC06_032/ov_SC06_032_jr_8016AB6C.c index 2b21798816..df56f4ad39 100644 --- a/src/ov_SC06_032/ov_SC06_032_jr_8016AB6C.c +++ b/src/ov_SC06_032/ov_SC06_032_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_032/ov_SC06_032_jr_80171B4C.c b/src/ov_SC06_032/ov_SC06_032_jr_80171B4C.c index 82dd1cb54f..665b424212 100644 --- a/src/ov_SC06_032/ov_SC06_032_jr_80171B4C.c +++ b/src/ov_SC06_032/ov_SC06_032_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_032/ov_SC06_032_jr_801734BC.c b/src/ov_SC06_032/ov_SC06_032_jr_801734BC.c index 9b978a8b96..c4126dc516 100644 --- a/src/ov_SC06_032/ov_SC06_032_jr_801734BC.c +++ b/src/ov_SC06_032/ov_SC06_032_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_032/ov_SC06_032_o0c.c b/src/ov_SC06_032/ov_SC06_032_o0c.c index c0e13b7912..170add69c4 100644 --- a/src/ov_SC06_032/ov_SC06_032_o0c.c +++ b/src/ov_SC06_032/ov_SC06_032_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC06_033/ov_SC06_033.c b/src/ov_SC06_033/ov_SC06_033.c index 890eaf56da..9384591fb9 100644 --- a/src/ov_SC06_033/ov_SC06_033.c +++ b/src/ov_SC06_033/ov_SC06_033.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC06_033/ov_SC06_033_after.c b/src/ov_SC06_033/ov_SC06_033_after.c index 0239782d18..ac8708bc3e 100644 --- a/src/ov_SC06_033/ov_SC06_033_after.c +++ b/src/ov_SC06_033/ov_SC06_033_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC06_033/ov_SC06_033_jr_8012ACE0.c b/src/ov_SC06_033/ov_SC06_033_jr_8012ACE0.c index 2205b31884..fdb4f0bd8c 100644 --- a/src/ov_SC06_033/ov_SC06_033_jr_8012ACE0.c +++ b/src/ov_SC06_033/ov_SC06_033_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC06_033/ov_SC06_033_jr_80135D20.c b/src/ov_SC06_033/ov_SC06_033_jr_80135D20.c index 16333b295a..903692f7e6 100644 --- a/src/ov_SC06_033/ov_SC06_033_jr_80135D20.c +++ b/src/ov_SC06_033/ov_SC06_033_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC06_033/ov_SC06_033_jr_801380E0.c b/src/ov_SC06_033/ov_SC06_033_jr_801380E0.c index 8004ad799f..dd2279443a 100644 --- a/src/ov_SC06_033/ov_SC06_033_jr_801380E0.c +++ b/src/ov_SC06_033/ov_SC06_033_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC06_033/ov_SC06_033_jr_8015AE2C.c b/src/ov_SC06_033/ov_SC06_033_jr_8015AE2C.c index 8ac47b3886..2a24dbddfa 100644 --- a/src/ov_SC06_033/ov_SC06_033_jr_8015AE2C.c +++ b/src/ov_SC06_033/ov_SC06_033_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC06_033/ov_SC06_033_jr_8015C32C.c b/src/ov_SC06_033/ov_SC06_033_jr_8015C32C.c index aae831fcf7..b1a25b5679 100644 --- a/src/ov_SC06_033/ov_SC06_033_jr_8015C32C.c +++ b/src/ov_SC06_033/ov_SC06_033_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC06_033/ov_SC06_033_jr_8016AB6C.c b/src/ov_SC06_033/ov_SC06_033_jr_8016AB6C.c index e3d083b644..26f8300d6a 100644 --- a/src/ov_SC06_033/ov_SC06_033_jr_8016AB6C.c +++ b/src/ov_SC06_033/ov_SC06_033_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC06_033/ov_SC06_033_jr_80171B4C.c b/src/ov_SC06_033/ov_SC06_033_jr_80171B4C.c index a552004e9a..93f9c33d10 100644 --- a/src/ov_SC06_033/ov_SC06_033_jr_80171B4C.c +++ b/src/ov_SC06_033/ov_SC06_033_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC06_033/ov_SC06_033_jr_801734BC.c b/src/ov_SC06_033/ov_SC06_033_jr_801734BC.c index 89a1d31c81..5269376e53 100644 --- a/src/ov_SC06_033/ov_SC06_033_jr_801734BC.c +++ b/src/ov_SC06_033/ov_SC06_033_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC06_033/ov_SC06_033_o0c.c b/src/ov_SC06_033/ov_SC06_033_o0c.c index 82e43af7b0..9ef3a2eef1 100644 --- a/src/ov_SC06_033/ov_SC06_033_o0c.c +++ b/src/ov_SC06_033/ov_SC06_033_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC07_000/ov_SC07_000.c b/src/ov_SC07_000/ov_SC07_000.c index a11d0194bd..e7047ef13c 100644 --- a/src/ov_SC07_000/ov_SC07_000.c +++ b/src/ov_SC07_000/ov_SC07_000.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC07_000/ov_SC07_000_after.c b/src/ov_SC07_000/ov_SC07_000_after.c index 7599ec2299..9ec7d27e09 100644 --- a/src/ov_SC07_000/ov_SC07_000_after.c +++ b/src/ov_SC07_000/ov_SC07_000_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC07_000/ov_SC07_000_jr_8012ACE0.c b/src/ov_SC07_000/ov_SC07_000_jr_8012ACE0.c index 4fdbe1bbec..a28a4f53ac 100644 --- a/src/ov_SC07_000/ov_SC07_000_jr_8012ACE0.c +++ b/src/ov_SC07_000/ov_SC07_000_jr_8012ACE0.c @@ -330,49 +330,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1107,23 +1065,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1156,29 +1098,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1940,25 +1860,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2061,15 +1963,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2101,37 +1995,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2555,35 +2419,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC07_000/ov_SC07_000_jr_80135D20.c b/src/ov_SC07_000/ov_SC07_000_jr_80135D20.c index 7d0c6aa6d6..fa6131a2d9 100644 --- a/src/ov_SC07_000/ov_SC07_000_jr_80135D20.c +++ b/src/ov_SC07_000/ov_SC07_000_jr_80135D20.c @@ -1340,17 +1340,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1394,32 +1384,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC07_000/ov_SC07_000_jr_801380E0.c b/src/ov_SC07_000/ov_SC07_000_jr_801380E0.c index e80ffb6ed2..f03e18fa21 100644 --- a/src/ov_SC07_000/ov_SC07_000_jr_801380E0.c +++ b/src/ov_SC07_000/ov_SC07_000_jr_801380E0.c @@ -1092,43 +1092,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC07_000/ov_SC07_000_jr_8015AE2C.c b/src/ov_SC07_000/ov_SC07_000_jr_8015AE2C.c index e2dd4837a0..4f33fd5a51 100644 --- a/src/ov_SC07_000/ov_SC07_000_jr_8015AE2C.c +++ b/src/ov_SC07_000/ov_SC07_000_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC07_000/ov_SC07_000_jr_8015C32C.c b/src/ov_SC07_000/ov_SC07_000_jr_8015C32C.c index 9031c5ca21..23a2f03ece 100644 --- a/src/ov_SC07_000/ov_SC07_000_jr_8015C32C.c +++ b/src/ov_SC07_000/ov_SC07_000_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC07_000/ov_SC07_000_jr_8016AB6C.c b/src/ov_SC07_000/ov_SC07_000_jr_8016AB6C.c index abae3fbc61..d24047ea49 100644 --- a/src/ov_SC07_000/ov_SC07_000_jr_8016AB6C.c +++ b/src/ov_SC07_000/ov_SC07_000_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC07_000/ov_SC07_000_jr_80171B4C.c b/src/ov_SC07_000/ov_SC07_000_jr_80171B4C.c index 052f3c8f1d..63548c5dec 100644 --- a/src/ov_SC07_000/ov_SC07_000_jr_80171B4C.c +++ b/src/ov_SC07_000/ov_SC07_000_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC07_000/ov_SC07_000_jr_801734BC.c b/src/ov_SC07_000/ov_SC07_000_jr_801734BC.c index 2928128345..89905f2d1d 100644 --- a/src/ov_SC07_000/ov_SC07_000_jr_801734BC.c +++ b/src/ov_SC07_000/ov_SC07_000_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC07_000/ov_SC07_000_o0c.c b/src/ov_SC07_000/ov_SC07_000_o0c.c index 9f10ee2d24..ab24fa6064 100644 --- a/src/ov_SC07_000/ov_SC07_000_o0c.c +++ b/src/ov_SC07_000/ov_SC07_000_o0c.c @@ -1017,24 +1017,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC07_001/ov_SC07_001.c b/src/ov_SC07_001/ov_SC07_001.c index 2100fa6b5a..ef6671a644 100644 --- a/src/ov_SC07_001/ov_SC07_001.c +++ b/src/ov_SC07_001/ov_SC07_001.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC07_001/ov_SC07_001_after.c b/src/ov_SC07_001/ov_SC07_001_after.c index 95af2d9c8b..79f3954f7f 100644 --- a/src/ov_SC07_001/ov_SC07_001_after.c +++ b/src/ov_SC07_001/ov_SC07_001_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC07_001/ov_SC07_001_jr_8012ACE0.c b/src/ov_SC07_001/ov_SC07_001_jr_8012ACE0.c index 77dfb6473b..4f6f68851b 100644 --- a/src/ov_SC07_001/ov_SC07_001_jr_8012ACE0.c +++ b/src/ov_SC07_001/ov_SC07_001_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC07_001/ov_SC07_001_jr_80135D20.c b/src/ov_SC07_001/ov_SC07_001_jr_80135D20.c index 660a1bdd64..a9bde0c3be 100644 --- a/src/ov_SC07_001/ov_SC07_001_jr_80135D20.c +++ b/src/ov_SC07_001/ov_SC07_001_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC07_001/ov_SC07_001_jr_801380E0.c b/src/ov_SC07_001/ov_SC07_001_jr_801380E0.c index 8c9fdf1938..c54e5e75bb 100644 --- a/src/ov_SC07_001/ov_SC07_001_jr_801380E0.c +++ b/src/ov_SC07_001/ov_SC07_001_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC07_001/ov_SC07_001_jr_8015AE2C.c b/src/ov_SC07_001/ov_SC07_001_jr_8015AE2C.c index bc254f85dd..71f28148c5 100644 --- a/src/ov_SC07_001/ov_SC07_001_jr_8015AE2C.c +++ b/src/ov_SC07_001/ov_SC07_001_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC07_001/ov_SC07_001_jr_8015C32C.c b/src/ov_SC07_001/ov_SC07_001_jr_8015C32C.c index c3f37e73de..29b096aed3 100644 --- a/src/ov_SC07_001/ov_SC07_001_jr_8015C32C.c +++ b/src/ov_SC07_001/ov_SC07_001_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC07_001/ov_SC07_001_jr_8016AB6C.c b/src/ov_SC07_001/ov_SC07_001_jr_8016AB6C.c index 157eb9a3e7..b637d8833a 100644 --- a/src/ov_SC07_001/ov_SC07_001_jr_8016AB6C.c +++ b/src/ov_SC07_001/ov_SC07_001_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC07_001/ov_SC07_001_jr_80171B4C.c b/src/ov_SC07_001/ov_SC07_001_jr_80171B4C.c index 7b5ced9584..5acf8380bc 100644 --- a/src/ov_SC07_001/ov_SC07_001_jr_80171B4C.c +++ b/src/ov_SC07_001/ov_SC07_001_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC07_001/ov_SC07_001_jr_801734BC.c b/src/ov_SC07_001/ov_SC07_001_jr_801734BC.c index 929cb6e5b9..0c596815f3 100644 --- a/src/ov_SC07_001/ov_SC07_001_jr_801734BC.c +++ b/src/ov_SC07_001/ov_SC07_001_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC07_001/ov_SC07_001_o0c.c b/src/ov_SC07_001/ov_SC07_001_o0c.c index 956f0d7ecc..338ad36d17 100644 --- a/src/ov_SC07_001/ov_SC07_001_o0c.c +++ b/src/ov_SC07_001/ov_SC07_001_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC07_002/ov_SC07_002.c b/src/ov_SC07_002/ov_SC07_002.c index 435528a8ee..dc5fde3d43 100644 --- a/src/ov_SC07_002/ov_SC07_002.c +++ b/src/ov_SC07_002/ov_SC07_002.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC07_002/ov_SC07_002_after.c b/src/ov_SC07_002/ov_SC07_002_after.c index a66b87d2dc..adfa256dea 100644 --- a/src/ov_SC07_002/ov_SC07_002_after.c +++ b/src/ov_SC07_002/ov_SC07_002_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC07_002/ov_SC07_002_jr_8012ACE0.c b/src/ov_SC07_002/ov_SC07_002_jr_8012ACE0.c index b985c481b6..64bf518de4 100644 --- a/src/ov_SC07_002/ov_SC07_002_jr_8012ACE0.c +++ b/src/ov_SC07_002/ov_SC07_002_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC07_002/ov_SC07_002_jr_80135D20.c b/src/ov_SC07_002/ov_SC07_002_jr_80135D20.c index 2696748754..8c31618d45 100644 --- a/src/ov_SC07_002/ov_SC07_002_jr_80135D20.c +++ b/src/ov_SC07_002/ov_SC07_002_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC07_002/ov_SC07_002_jr_801380E0.c b/src/ov_SC07_002/ov_SC07_002_jr_801380E0.c index 9741e87099..bebf33b865 100644 --- a/src/ov_SC07_002/ov_SC07_002_jr_801380E0.c +++ b/src/ov_SC07_002/ov_SC07_002_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC07_002/ov_SC07_002_jr_8015AE2C.c b/src/ov_SC07_002/ov_SC07_002_jr_8015AE2C.c index 684fae99c0..5ddef28c11 100644 --- a/src/ov_SC07_002/ov_SC07_002_jr_8015AE2C.c +++ b/src/ov_SC07_002/ov_SC07_002_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC07_002/ov_SC07_002_jr_8015C32C.c b/src/ov_SC07_002/ov_SC07_002_jr_8015C32C.c index 522848db66..7dece8b961 100644 --- a/src/ov_SC07_002/ov_SC07_002_jr_8015C32C.c +++ b/src/ov_SC07_002/ov_SC07_002_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC07_002/ov_SC07_002_jr_8016AB6C.c b/src/ov_SC07_002/ov_SC07_002_jr_8016AB6C.c index 8e1a05f14d..19a7f0a43d 100644 --- a/src/ov_SC07_002/ov_SC07_002_jr_8016AB6C.c +++ b/src/ov_SC07_002/ov_SC07_002_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC07_002/ov_SC07_002_jr_80171B4C.c b/src/ov_SC07_002/ov_SC07_002_jr_80171B4C.c index 8d75cd0120..73281c592d 100644 --- a/src/ov_SC07_002/ov_SC07_002_jr_80171B4C.c +++ b/src/ov_SC07_002/ov_SC07_002_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC07_002/ov_SC07_002_jr_801734BC.c b/src/ov_SC07_002/ov_SC07_002_jr_801734BC.c index fbd5c988a4..0872d2b74d 100644 --- a/src/ov_SC07_002/ov_SC07_002_jr_801734BC.c +++ b/src/ov_SC07_002/ov_SC07_002_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC07_002/ov_SC07_002_o0c.c b/src/ov_SC07_002/ov_SC07_002_o0c.c index 4ef0cd01ab..fc3af778a6 100644 --- a/src/ov_SC07_002/ov_SC07_002_o0c.c +++ b/src/ov_SC07_002/ov_SC07_002_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC07_006/ov_SC07_006.c b/src/ov_SC07_006/ov_SC07_006.c index 6d934ca29b..87ea942847 100644 --- a/src/ov_SC07_006/ov_SC07_006.c +++ b/src/ov_SC07_006/ov_SC07_006.c @@ -756,14 +756,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129cf8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129ff4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012a048 (src/shared) */ @@ -790,34 +783,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012a110 (src/shared) */ // stores stops gcc hoisting the first 8-byte block copy above them. -extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; -extern s16 D_80120210; -extern s16 D_80120220; -extern s32 D_80120294; -extern s16 D_80120298; - -extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; -extern Blk8 D_80126960, D_80126968; -extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; -extern s32 D_801269E4; -extern u16 D_801269E8, D_801269EA; - -void func_8012A1BC(void) { - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012a2f4 (src/shared) */ @@ -1149,49 +1115,7 @@ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012b744 (src/shared) */ // @stuck: none — MATCH (58 ins) #include "common.h" -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012b864 (src/shared) */ @@ -2121,23 +2045,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012ef70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ DEFINE_func_8012F038() /* dedup: shared engine-core @0x8012f038 (src/shared) */ diff --git a/src/ov_SC07_006/ov_SC07_006_jr_80131340.c b/src/ov_SC07_006/ov_SC07_006_jr_80131340.c index 0b0da77191..43b0ca1845 100644 --- a/src/ov_SC07_006/ov_SC07_006_jr_80131340.c +++ b/src/ov_SC07_006/ov_SC07_006_jr_80131340.c @@ -821,25 +821,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319e0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131ac8 (src/shared) */ @@ -948,15 +930,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -988,37 +962,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131d68 (src/shared) */ @@ -1480,35 +1424,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339c (src/shared) */ diff --git a/src/ov_SC07_006/ov_SC07_006_jr_80135D20.c b/src/ov_SC07_006/ov_SC07_006_jr_80135D20.c index f79353724c..5aa88190b1 100644 --- a/src/ov_SC07_006/ov_SC07_006_jr_80135D20.c +++ b/src/ov_SC07_006/ov_SC07_006_jr_80135D20.c @@ -1324,17 +1324,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767c (src/shared) */ diff --git a/src/ov_SC07_006/ov_SC07_006_jr_801380E0.c b/src/ov_SC07_006/ov_SC07_006_jr_801380E0.c index 3e3f8458c5..aeecf42f1d 100644 --- a/src/ov_SC07_006/ov_SC07_006_jr_801380E0.c +++ b/src/ov_SC07_006/ov_SC07_006_jr_801380E0.c @@ -1138,42 +1138,7 @@ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138db8 (src/shared) */ */ #include "common.h" -extern s32 D_80127548[]; -extern u8 D_800D3AB4[]; -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ed0 (src/shared) */ diff --git a/src/ov_SC07_006/ov_SC07_006_jr_801457A4.c b/src/ov_SC07_006/ov_SC07_006_jr_801457A4.c index 929461700a..8c667b893a 100644 --- a/src/ov_SC07_006/ov_SC07_006_jr_801457A4.c +++ b/src/ov_SC07_006/ov_SC07_006_jr_801457A4.c @@ -2149,31 +2149,7 @@ void func_80149584(s32 arg0, s32 arg1, s32 arg2) { * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT * `register __asm__("$N")` pins. */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -2510,48 +2486,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014a71c (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014a830 (src/shared) */ @@ -2792,38 +2727,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014c43c (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ DEFINE_func_8014C568() /* dedup: shared engine-core @0x8014C568 (src/shared) */ @@ -3264,38 +3168,7 @@ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ #include "common.h" -extern u8 D_801202A0[]; -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) -{ - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -3766,40 +3639,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC07_006/ov_SC07_006_jr_8015B950.c b/src/ov_SC07_006/ov_SC07_006_jr_8015B950.c index e848085e53..c2edf89287 100644 --- a/src/ov_SC07_006/ov_SC07_006_jr_8015B950.c +++ b/src/ov_SC07_006/ov_SC07_006_jr_8015B950.c @@ -2348,20 +2348,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015c08c (src/shared) */ diff --git a/src/ov_SC07_006/ov_SC07_006_jr_8015C32C.c b/src/ov_SC07_006/ov_SC07_006_jr_8015C32C.c index d9c4bbd9c1..fb21c35103 100644 --- a/src/ov_SC07_006/ov_SC07_006_jr_8015C32C.c +++ b/src/ov_SC07_006/ov_SC07_006_jr_8015C32C.c @@ -4353,32 +4353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @class: schedule // @stuck: none — MATCH -extern int D_801152BC; - -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) -{ - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ /* de-macroized: per-overlay-local decl for func_8016163C (byte-true sig); do NOT re-macroize */ @@ -4546,58 +4521,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197c (src/shared) */ @@ -5253,21 +5177,7 @@ void func_80162CC4(void) { extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162d28 (src/shared) */ @@ -5364,51 +5274,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ diff --git a/src/ov_SC07_006/ov_SC07_006_jr_8016AE5C.c b/src/ov_SC07_006/ov_SC07_006_jr_8016AE5C.c index 6e75de72b8..4bf45d6e87 100644 --- a/src/ov_SC07_006/ov_SC07_006_jr_8016AE5C.c +++ b/src/ov_SC07_006/ov_SC07_006_jr_8016AE5C.c @@ -4757,37 +4757,7 @@ void func_8016F0AC(void) { * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016f14c (src/shared) */ @@ -5251,26 +5221,7 @@ DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084c (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -5337,38 +5288,7 @@ DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170cb0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC07_006/ov_SC07_006_jr_80171B4C.c b/src/ov_SC07_006/ov_SC07_006_jr_80171B4C.c index cab6cd3856..3b4fe5e954 100644 --- a/src/ov_SC07_006/ov_SC07_006_jr_80171B4C.c +++ b/src/ov_SC07_006/ov_SC07_006_jr_80171B4C.c @@ -3164,14 +3164,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172bc8 (src/shared) */ void func_80172C48(void) { } -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -3319,18 +3312,7 @@ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733cc (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ @@ -3454,40 +3436,7 @@ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173a28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -3705,49 +3654,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749a8 (src/shared) */ -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174b6c (src/shared) */ @@ -4031,37 +3938,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757e0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -4885,42 +4762,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) -{ - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ diff --git a/src/ov_SC07_006/ov_SC07_006_o0c.c b/src/ov_SC07_006/ov_SC07_006_o0c.c index 301cbccf63..6af3fc044a 100644 --- a/src/ov_SC07_006/ov_SC07_006_o0c.c +++ b/src/ov_SC07_006/ov_SC07_006_o0c.c @@ -960,24 +960,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC07_007/ov_SC07_007.c b/src/ov_SC07_007/ov_SC07_007.c index abf7225a03..7fce70394a 100644 --- a/src/ov_SC07_007/ov_SC07_007.c +++ b/src/ov_SC07_007/ov_SC07_007.c @@ -756,14 +756,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129cf8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129ff4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012a048 (src/shared) */ @@ -794,40 +787,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012a110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012a2f4 (src/shared) */ @@ -1137,49 +1097,7 @@ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012b744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012b864 (src/shared) */ @@ -1972,23 +1890,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012ef70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ DEFINE_func_8012F038() /* dedup: shared engine-core @0x8012f038 (src/shared) */ @@ -2019,29 +1921,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012f374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ diff --git a/src/ov_SC07_007/ov_SC07_007_jr_80131340.c b/src/ov_SC07_007/ov_SC07_007_jr_80131340.c index 6b672855f9..003e3fee66 100644 --- a/src/ov_SC07_007/ov_SC07_007_jr_80131340.c +++ b/src/ov_SC07_007/ov_SC07_007_jr_80131340.c @@ -821,25 +821,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319e0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131ac8 (src/shared) */ @@ -948,15 +930,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -988,37 +962,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131d68 (src/shared) */ @@ -1477,35 +1421,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339c (src/shared) */ diff --git a/src/ov_SC07_007/ov_SC07_007_jr_80135D20.c b/src/ov_SC07_007/ov_SC07_007_jr_80135D20.c index f4f4239d81..16c86e11a7 100644 --- a/src/ov_SC07_007/ov_SC07_007_jr_80135D20.c +++ b/src/ov_SC07_007/ov_SC07_007_jr_80135D20.c @@ -1274,17 +1274,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767c (src/shared) */ diff --git a/src/ov_SC07_007/ov_SC07_007_jr_801380E0.c b/src/ov_SC07_007/ov_SC07_007_jr_801380E0.c index 0994a913d2..36168ea8e9 100644 --- a/src/ov_SC07_007/ov_SC07_007_jr_801380E0.c +++ b/src/ov_SC07_007/ov_SC07_007_jr_801380E0.c @@ -1064,43 +1064,7 @@ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138db8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ed0 (src/shared) */ diff --git a/src/ov_SC07_007/ov_SC07_007_jr_801457A4.c b/src/ov_SC07_007/ov_SC07_007_jr_801457A4.c index 1419b18a19..dda9b19ba0 100644 --- a/src/ov_SC07_007/ov_SC07_007_jr_801457A4.c +++ b/src/ov_SC07_007/ov_SC07_007_jr_801457A4.c @@ -2089,31 +2089,7 @@ void func_80149584(s32 arg0, s32 arg1, s32 arg2) { * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT * `register __asm__("$N")` pins. */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -2466,52 +2442,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014a71c (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014a830 (src/shared) */ @@ -2752,38 +2683,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014c43c (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ DEFINE_func_8014C568() /* dedup: shared engine-core @0x8014C568 (src/shared) */ @@ -3038,40 +2938,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014d438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -3548,41 +3415,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC07_007/ov_SC07_007_jr_8015B950.c b/src/ov_SC07_007/ov_SC07_007_jr_8015B950.c index f54aa2f373..99a1e63c8e 100644 --- a/src/ov_SC07_007/ov_SC07_007_jr_8015B950.c +++ b/src/ov_SC07_007/ov_SC07_007_jr_8015B950.c @@ -2349,20 +2349,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015c08c (src/shared) */ diff --git a/src/ov_SC07_007/ov_SC07_007_jr_8015C32C.c b/src/ov_SC07_007/ov_SC07_007_jr_8015C32C.c index 9d0267a054..c0aef778b2 100644 --- a/src/ov_SC07_007/ov_SC07_007_jr_8015C32C.c +++ b/src/ov_SC07_007/ov_SC07_007_jr_8015C32C.c @@ -4342,31 +4342,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -4499,58 +4475,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197c (src/shared) */ @@ -5206,21 +5131,7 @@ void func_80162CC4(void) { extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162d28 (src/shared) */ @@ -5317,51 +5228,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ diff --git a/src/ov_SC07_007/ov_SC07_007_jr_8016AE5C.c b/src/ov_SC07_007/ov_SC07_007_jr_8016AE5C.c index e2f8cb708a..05f944f116 100644 --- a/src/ov_SC07_007/ov_SC07_007_jr_8016AE5C.c +++ b/src/ov_SC07_007/ov_SC07_007_jr_8016AE5C.c @@ -4745,37 +4745,7 @@ void func_8016F0AC(void) { * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016f14c (src/shared) */ @@ -5239,26 +5209,7 @@ DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084c (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -5325,38 +5276,7 @@ DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170cb0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC07_007/ov_SC07_007_jr_80171B4C.c b/src/ov_SC07_007/ov_SC07_007_jr_80171B4C.c index 736f0cdcbb..edeab99e3c 100644 --- a/src/ov_SC07_007/ov_SC07_007_jr_80171B4C.c +++ b/src/ov_SC07_007/ov_SC07_007_jr_80171B4C.c @@ -3152,14 +3152,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172bc8 (src/shared) */ void func_80172C48(void) { } -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -3307,18 +3300,7 @@ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733cc (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ @@ -3442,40 +3424,7 @@ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173a28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -3697,49 +3646,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749a8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174b6c (src/shared) */ @@ -3967,37 +3874,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757e0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -4007,43 +3884,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -4828,41 +4669,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC07_007/ov_SC07_007_o0c.c b/src/ov_SC07_007/ov_SC07_007_o0c.c index f46442be61..dad4c8cb54 100644 --- a/src/ov_SC07_007/ov_SC07_007_o0c.c +++ b/src/ov_SC07_007/ov_SC07_007_o0c.c @@ -960,24 +960,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC07_008/ov_SC07_008.c b/src/ov_SC07_008/ov_SC07_008.c index 09a442ca70..f2d88b06a6 100644 --- a/src/ov_SC07_008/ov_SC07_008.c +++ b/src/ov_SC07_008/ov_SC07_008.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC07_008/ov_SC07_008_after.c b/src/ov_SC07_008/ov_SC07_008_after.c index caa3a3759f..572cdb6c1e 100644 --- a/src/ov_SC07_008/ov_SC07_008_after.c +++ b/src/ov_SC07_008/ov_SC07_008_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC07_008/ov_SC07_008_jr_8012ACE0.c b/src/ov_SC07_008/ov_SC07_008_jr_8012ACE0.c index 3fbd7537e6..a394ee571d 100644 --- a/src/ov_SC07_008/ov_SC07_008_jr_8012ACE0.c +++ b/src/ov_SC07_008/ov_SC07_008_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC07_008/ov_SC07_008_jr_80135D20.c b/src/ov_SC07_008/ov_SC07_008_jr_80135D20.c index e986635165..0cb239846c 100644 --- a/src/ov_SC07_008/ov_SC07_008_jr_80135D20.c +++ b/src/ov_SC07_008/ov_SC07_008_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC07_008/ov_SC07_008_jr_801380E0.c b/src/ov_SC07_008/ov_SC07_008_jr_801380E0.c index 3679e35f7d..66f1ab78b5 100644 --- a/src/ov_SC07_008/ov_SC07_008_jr_801380E0.c +++ b/src/ov_SC07_008/ov_SC07_008_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC07_008/ov_SC07_008_jr_8015AE2C.c b/src/ov_SC07_008/ov_SC07_008_jr_8015AE2C.c index 1808a3298a..656bbc75bd 100644 --- a/src/ov_SC07_008/ov_SC07_008_jr_8015AE2C.c +++ b/src/ov_SC07_008/ov_SC07_008_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC07_008/ov_SC07_008_jr_8015C32C.c b/src/ov_SC07_008/ov_SC07_008_jr_8015C32C.c index de9e12fcbf..d2bfe2f5ab 100644 --- a/src/ov_SC07_008/ov_SC07_008_jr_8015C32C.c +++ b/src/ov_SC07_008/ov_SC07_008_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5394,25 +5261,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC07_008/ov_SC07_008_jr_8016AB6C.c b/src/ov_SC07_008/ov_SC07_008_jr_8016AB6C.c index 1c15b6eca8..efb872bc23 100644 --- a/src/ov_SC07_008/ov_SC07_008_jr_8016AB6C.c +++ b/src/ov_SC07_008/ov_SC07_008_jr_8016AB6C.c @@ -2553,21 +2553,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3890,37 +3876,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4285,26 +4241,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4356,38 +4293,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC07_008/ov_SC07_008_jr_80171B4C.c b/src/ov_SC07_008/ov_SC07_008_jr_80171B4C.c index 45d61e99f9..b967260f09 100644 --- a/src/ov_SC07_008/ov_SC07_008_jr_80171B4C.c +++ b/src/ov_SC07_008/ov_SC07_008_jr_80171B4C.c @@ -2421,14 +2421,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2545,18 +2538,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC07_008/ov_SC07_008_jr_801734BC.c b/src/ov_SC07_008/ov_SC07_008_jr_801734BC.c index 1e591aff71..8cf5514126 100644 --- a/src/ov_SC07_008/ov_SC07_008_jr_801734BC.c +++ b/src/ov_SC07_008/ov_SC07_008_jr_801734BC.c @@ -2411,40 +2411,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2618,49 +2585,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2860,38 +2785,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2901,44 +2795,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3729,41 +3586,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC07_008/ov_SC07_008_o0c.c b/src/ov_SC07_008/ov_SC07_008_o0c.c index a2fcc8efd8..15cb343f2b 100644 --- a/src/ov_SC07_008/ov_SC07_008_o0c.c +++ b/src/ov_SC07_008/ov_SC07_008_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC07_009/ov_SC07_009.c b/src/ov_SC07_009/ov_SC07_009.c index 44546006d7..f298659590 100644 --- a/src/ov_SC07_009/ov_SC07_009.c +++ b/src/ov_SC07_009/ov_SC07_009.c @@ -677,14 +677,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129CF8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129FF4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012A048 (src/shared) */ @@ -710,40 +703,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012A110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012A2F4 (src/shared) */ diff --git a/src/ov_SC07_009/ov_SC07_009_after.c b/src/ov_SC07_009/ov_SC07_009_after.c index 5e19347eee..09c9ce0197 100644 --- a/src/ov_SC07_009/ov_SC07_009_after.c +++ b/src/ov_SC07_009/ov_SC07_009_after.c @@ -903,52 +903,7 @@ DEFINE_func_80149544() /* dedup: shared engine-core @0x80149544 (src/shared) */ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ -extern void func_8014964C(s32 param_1, s32 param_2); - -/* func_801495C4 (ov_SC01_077, 34 ins) — clone of the banked sibling func_8014964C. - * - * REGISTER-PIN-FREE byte-match (close=0). The sibling's engine_core.h macro pins - * `register s32 p2 __asm__("$16")` to force a1->$s0; that pin is REMOVED here — once - * the &buf CSE-hoist is broken, natural density allocation puts a1 in $s0 by itself - * (a1: 7 refs / 21 insns crosses 2 calls; &buf pseudo out-densities it otherwise). - * - * Wall (pure-C, zero-asm): gcc-2.7.2 CSE commons the two identical stack-address - * computations `&buf` (sp+0x20, passed to both calls) into ONE call-crossing pseudo, - * which then wins $s0 over a1 (RC-2/K2 density) and spills a1 to $s1 (frame 0x30->0x38). - * v1 (buf declared first, buf@sp+0x10) rematerializes &buf and matches everything but - * the in/buf slot offsets; but correct slots REQUIRE `in,result,buf` decl order, which - * puts buf@sp+0x20 and triggers the hoist. Every zero-asm CSE-break tried (2 pointer - * vars, single ptr 2-set, struct, (char*)result+8, buf[z-z], a1&0, volatile ptr) is - * folded/re-commoned by gcc. The two `m1/m2` reg-tie barriers below make the two &buf - * opaque so each is materialized fresh (as the target does); `pin`/`mtx` barriers fix - * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT - * `register __asm__("$N")` pins. - */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -1124,50 +1079,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014A71C (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014A830 (src/shared) */ @@ -1340,38 +1252,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014C43C (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ @@ -1593,38 +1474,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014D438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2090,41 +1940,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC07_009/ov_SC07_009_jr_8012ACE0.c b/src/ov_SC07_009/ov_SC07_009_jr_8012ACE0.c index 1cd0a42f91..cf00058f78 100644 --- a/src/ov_SC07_009/ov_SC07_009_jr_8012ACE0.c +++ b/src/ov_SC07_009/ov_SC07_009_jr_8012ACE0.c @@ -328,49 +328,7 @@ DEFINE_func_8012B70C() /* dedup: shared engine-core @0x8012B70C (src/shared) */ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012B744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012B864 (src/shared) */ @@ -1105,23 +1063,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012EF70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ @@ -1154,29 +1096,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012F374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ @@ -1938,25 +1858,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319E0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131AC8 (src/shared) */ @@ -2059,15 +1961,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -2099,37 +1993,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131D68 (src/shared) */ @@ -2553,35 +2417,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339C (src/shared) */ diff --git a/src/ov_SC07_009/ov_SC07_009_jr_80135D20.c b/src/ov_SC07_009/ov_SC07_009_jr_80135D20.c index 3d29d187c5..3abb7de3b9 100644 --- a/src/ov_SC07_009/ov_SC07_009_jr_80135D20.c +++ b/src/ov_SC07_009/ov_SC07_009_jr_80135D20.c @@ -1338,17 +1338,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767C (src/shared) */ @@ -1392,32 +1382,7 @@ extern void func_80139BE0(s32 a0); void *aF801376E8(int a0, int a1) __asm__("func_801376E8"); -void *aF801376E8(int a0, int a1) -{ - - extern s32 D_801269F0; - extern u8 D_801269FD; - extern u16 D_80126A14[]; - extern s16 D_80126A1C; - extern s16 D_80126A20; - extern s16 D_80126A22; - extern s16 D_80126A24; - extern u16 D_80126A26; - u16 *p = (u16 *)a1; - s32 obj = (s32)&D_801269F0; - - func_801377B4(a0, 0x6200, obj); - D_80126A1C = 0x1C; - D_801269FD = 0; - if (p != 0) { - D_80126A14[0] = p[0]; - D_80126A14[1] = p[1]; - } - func_80139BE0(obj); - D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); - D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); - return (void *)obj; -} +DEFINE_func_801376E8() /* dedup: shared engine-core @0x801376E8 (src/shared) */ DEFINE_func_801377B4() /* dedup: shared engine-core @0x801377B4 (src/shared) */ diff --git a/src/ov_SC07_009/ov_SC07_009_jr_801380E0.c b/src/ov_SC07_009/ov_SC07_009_jr_801380E0.c index a2819fb6c7..1380b2a4e7 100644 --- a/src/ov_SC07_009/ov_SC07_009_jr_801380E0.c +++ b/src/ov_SC07_009/ov_SC07_009_jr_801380E0.c @@ -1097,43 +1097,7 @@ DEFINE_func_80138D58() /* dedup: shared engine-core @0x80138D58 (src/shared) */ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138DB8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ED0 (src/shared) */ diff --git a/src/ov_SC07_009/ov_SC07_009_jr_8015AE2C.c b/src/ov_SC07_009/ov_SC07_009_jr_8015AE2C.c index 0f050be553..3860df74dc 100644 --- a/src/ov_SC07_009/ov_SC07_009_jr_8015AE2C.c +++ b/src/ov_SC07_009/ov_SC07_009_jr_8015AE2C.c @@ -1815,20 +1815,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015C08C (src/shared) */ diff --git a/src/ov_SC07_009/ov_SC07_009_jr_8015C32C.c b/src/ov_SC07_009/ov_SC07_009_jr_8015C32C.c index 7de4ad7aad..2a37e838ba 100644 --- a/src/ov_SC07_009/ov_SC07_009_jr_8015C32C.c +++ b/src/ov_SC07_009/ov_SC07_009_jr_8015C32C.c @@ -3353,31 +3353,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3502,58 +3478,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ @@ -4189,21 +4114,7 @@ DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ @@ -4279,51 +4190,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ @@ -5393,25 +5260,7 @@ s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -extern void func_80146C3C(void); - -void func_8016706C(s32 param_1) -{ - - extern s32 D_8011D030; - unsigned short *puVar1; - short iVar2; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - do { - if ((unsigned int)*puVar1 == ((short)param_1)) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); -} +DEFINE_func_8016706C() /* dedup: shared engine-core @0x8016706C (src/shared) */ diff --git a/src/ov_SC07_009/ov_SC07_009_jr_8016AB6C.c b/src/ov_SC07_009/ov_SC07_009_jr_8016AB6C.c index 38736c5b23..7f62bd3b3b 100644 --- a/src/ov_SC07_009/ov_SC07_009_jr_8016AB6C.c +++ b/src/ov_SC07_009/ov_SC07_009_jr_8016AB6C.c @@ -2554,21 +2554,7 @@ DEFINE_func_8016BF34() /* dedup: shared engine-core @0x8016BF34 (src/shared) */ /* §71 sibling-first: this is the head of the already-matched func_8016C2C4 * (src/ov_SC03_099/ov_SC03_099_jr_8016AB6C.c L2707) lifted into its own leaf. */ -extern void func_80149350(s32 arg0); -extern void func_80015954(s32 a0, s32 a1); - -s32 func_8016BF50(s32 param) -{ - u16 buf[3]; - s32 arg; - - arg = *(s32 *)(param + 0x34); - buf[0] = *(u16 *)(param + 0x12); - buf[1] = *(u16 *)(param + 0x16); - buf[2] = *(u16 *)(param + 0x1a); - ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); - ((void (*)(void *, s32))func_80015954)(buf, param + 4); -} +DEFINE_func_8016BF50() /* dedup: shared engine-core @0x8016BF50 (src/shared) */ @@ -3891,37 +3877,7 @@ s32 func_8016F0AC() * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016F14C (src/shared) */ @@ -4286,26 +4242,7 @@ void func_80170810(void *a0) { DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084C (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4357,38 +4294,7 @@ void func_80170C74(void *a0) { DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170CB0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC07_009/ov_SC07_009_jr_80171B4C.c b/src/ov_SC07_009/ov_SC07_009_jr_80171B4C.c index cf1e45edaf..4fdedd3787 100644 --- a/src/ov_SC07_009/ov_SC07_009_jr_80171B4C.c +++ b/src/ov_SC07_009/ov_SC07_009_jr_80171B4C.c @@ -2422,14 +2422,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172BC8 (src/shared) */ DEFINE_func_80172C48() /* dedup: shared engine-core @0x80172C48 (src/shared) */ -extern void func_80174684(void *); -extern void func_80172CA0(void*); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2546,18 +2539,7 @@ DEFINE_func_801733A4() /* dedup: shared engine-core @0x801733A4 (src/shared) */ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733CC (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ diff --git a/src/ov_SC07_009/ov_SC07_009_jr_801734BC.c b/src/ov_SC07_009/ov_SC07_009_jr_801734BC.c index 29fcfa7f92..5f716a4063 100644 --- a/src/ov_SC07_009/ov_SC07_009_jr_801734BC.c +++ b/src/ov_SC07_009/ov_SC07_009_jr_801734BC.c @@ -2412,40 +2412,7 @@ DEFINE_func_80173A20() /* dedup: shared engine-core @0x80173A20 (src/shared) */ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173A28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void*); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -2619,49 +2586,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749A8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174B6C (src/shared) */ @@ -2861,38 +2786,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757E0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -2902,44 +2796,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -3730,41 +3587,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC07_009/ov_SC07_009_o0c.c b/src/ov_SC07_009/ov_SC07_009_o0c.c index 8f4a7576ef..26ba71c718 100644 --- a/src/ov_SC07_009/ov_SC07_009_o0c.c +++ b/src/ov_SC07_009/ov_SC07_009_o0c.c @@ -1015,24 +1015,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC07_010/ov_SC07_010.c b/src/ov_SC07_010/ov_SC07_010.c index 63806e1c40..5b25989489 100644 --- a/src/ov_SC07_010/ov_SC07_010.c +++ b/src/ov_SC07_010/ov_SC07_010.c @@ -756,14 +756,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129cf8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129ff4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012a048 (src/shared) */ @@ -794,40 +787,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012a110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012a2f4 (src/shared) */ @@ -1137,49 +1097,7 @@ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012b744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012b864 (src/shared) */ @@ -1972,23 +1890,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012ef70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ DEFINE_func_8012F038() /* dedup: shared engine-core @0x8012f038 (src/shared) */ @@ -2019,29 +1921,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012f374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ diff --git a/src/ov_SC07_010/ov_SC07_010_jr_80131340.c b/src/ov_SC07_010/ov_SC07_010_jr_80131340.c index 49b2f496e7..1f860f954a 100644 --- a/src/ov_SC07_010/ov_SC07_010_jr_80131340.c +++ b/src/ov_SC07_010/ov_SC07_010_jr_80131340.c @@ -826,25 +826,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319e0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131ac8 (src/shared) */ @@ -953,15 +935,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -993,37 +967,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131d68 (src/shared) */ @@ -1482,35 +1426,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339c (src/shared) */ diff --git a/src/ov_SC07_010/ov_SC07_010_jr_80135D20.c b/src/ov_SC07_010/ov_SC07_010_jr_80135D20.c index cb1a47c144..3b14a27426 100644 --- a/src/ov_SC07_010/ov_SC07_010_jr_80135D20.c +++ b/src/ov_SC07_010/ov_SC07_010_jr_80135D20.c @@ -1279,17 +1279,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767c (src/shared) */ diff --git a/src/ov_SC07_010/ov_SC07_010_jr_801380E0.c b/src/ov_SC07_010/ov_SC07_010_jr_801380E0.c index 7a3af7807c..eb6f453062 100644 --- a/src/ov_SC07_010/ov_SC07_010_jr_801380E0.c +++ b/src/ov_SC07_010/ov_SC07_010_jr_801380E0.c @@ -1070,43 +1070,7 @@ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138db8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ed0 (src/shared) */ diff --git a/src/ov_SC07_010/ov_SC07_010_jr_801457A4.c b/src/ov_SC07_010/ov_SC07_010_jr_801457A4.c index 8bfcd03927..0fe1568305 100644 --- a/src/ov_SC07_010/ov_SC07_010_jr_801457A4.c +++ b/src/ov_SC07_010/ov_SC07_010_jr_801457A4.c @@ -1425,31 +1425,7 @@ DEFINE_func_80149584() /* dedup: shared engine-core @0x80149584 (src/shared) */ * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT * `register __asm__("$N")` pins. */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ DEFINE_func_8014964C() /* dedup: shared engine-core @0x8014964c (src/shared) */ @@ -1661,52 +1637,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014a71c (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014a830 (src/shared) */ @@ -1947,38 +1878,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014c43c (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ DEFINE_func_8014C568() /* dedup: shared engine-core @0x8014C568 (src/shared) */ @@ -2233,40 +2133,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014d438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -2740,41 +2607,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC07_010/ov_SC07_010_jr_8015B950.c b/src/ov_SC07_010/ov_SC07_010_jr_8015B950.c index d39d893563..480f1f2645 100644 --- a/src/ov_SC07_010/ov_SC07_010_jr_8015B950.c +++ b/src/ov_SC07_010/ov_SC07_010_jr_8015B950.c @@ -1776,20 +1776,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015c08c (src/shared) */ diff --git a/src/ov_SC07_010/ov_SC07_010_jr_8015C32C.c b/src/ov_SC07_010/ov_SC07_010_jr_8015C32C.c index 64ba7181fa..f96a28d879 100644 --- a/src/ov_SC07_010/ov_SC07_010_jr_8015C32C.c +++ b/src/ov_SC07_010/ov_SC07_010_jr_8015C32C.c @@ -3769,31 +3769,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -3926,58 +3902,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197c (src/shared) */ @@ -4633,21 +4558,7 @@ void func_80162CC4(void) { extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162d28 (src/shared) */ @@ -4744,51 +4655,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ diff --git a/src/ov_SC07_010/ov_SC07_010_jr_8016AE5C.c b/src/ov_SC07_010/ov_SC07_010_jr_8016AE5C.c index 99039ebdbc..1d87309f08 100644 --- a/src/ov_SC07_010/ov_SC07_010_jr_8016AE5C.c +++ b/src/ov_SC07_010/ov_SC07_010_jr_8016AE5C.c @@ -4196,37 +4196,7 @@ void aF8016F0AC(void) * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016f14c (src/shared) */ @@ -4690,26 +4660,7 @@ DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084c (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -4776,38 +4727,7 @@ DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170cb0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC07_010/ov_SC07_010_jr_80171B4C.c b/src/ov_SC07_010/ov_SC07_010_jr_80171B4C.c index 1b4b0b9abe..cb726519f0 100644 --- a/src/ov_SC07_010/ov_SC07_010_jr_80171B4C.c +++ b/src/ov_SC07_010/ov_SC07_010_jr_80171B4C.c @@ -2595,14 +2595,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172bc8 (src/shared) */ void func_80172C48(void) { } -extern void func_80174684(void *); -extern void func_80172CA0(void *a0); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -2750,18 +2743,7 @@ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733cc (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ @@ -2885,41 +2867,7 @@ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173a28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void *a0); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) -{ - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -3141,49 +3089,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749a8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174b6c (src/shared) */ @@ -3412,38 +3318,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757e0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern s16 D_800B9A02; - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -3453,44 +3328,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern s16 D_800B9A02; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -4275,41 +4113,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC07_010/ov_SC07_010_jr_8017AE2C.c b/src/ov_SC07_010/ov_SC07_010_jr_8017AE2C.c index c0f1010f4d..1b747e899b 100644 --- a/src/ov_SC07_010/ov_SC07_010_jr_8017AE2C.c +++ b/src/ov_SC07_010/ov_SC07_010_jr_8017AE2C.c @@ -4259,8 +4259,7 @@ INCLUDE_ASM("asm/ov_SC07_010/nonmatchings/ov_SC07_010_jr_8017AE2C", func_8017E3E INCLUDE_ASM("asm/ov_SC07_010/nonmatchings/ov_SC07_010_jr_8017AE2C", func_8017E4D0); -void func_8017E518(void) { -} +DEFINE_func_8017E518() /* dedup: shared engine-core @0x8017E518 (src/shared) */ INCLUDE_ASM("asm/ov_SC07_010/nonmatchings/ov_SC07_010_jr_8017AE2C", func_8017E520); diff --git a/src/ov_SC07_010/ov_SC07_010_o0.c b/src/ov_SC07_010/ov_SC07_010_o0.c index 4c957dfbd4..e356fd94cf 100644 --- a/src/ov_SC07_010/ov_SC07_010_o0.c +++ b/src/ov_SC07_010/ov_SC07_010_o0.c @@ -267,24 +267,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/ov_SC07_011/ov_SC07_011.c b/src/ov_SC07_011/ov_SC07_011.c index 5999db9f22..168491a662 100644 --- a/src/ov_SC07_011/ov_SC07_011.c +++ b/src/ov_SC07_011/ov_SC07_011.c @@ -756,14 +756,7 @@ DEFINE_func_80129CF8() /* dedup: shared engine-core @0x80129cf8 (src/shared) */ DEFINE_func_80129FF4() /* dedup: shared engine-core @0x80129ff4 (src/shared) */ -extern void func_8012A048(void *a0, s32 a1, u8 a2); - -void func_8012A018(s32 a0, s32 a1) -{ - extern u8 D_80126948[]; - - func_8012A048(D_80126948, a0, a1); -} +DEFINE_func_8012A018() /* dedup: shared engine-core @0x8012A018 (src/shared) */ DEFINE_func_8012A048() /* dedup: shared engine-core @0x8012a048 (src/shared) */ @@ -794,40 +787,7 @@ DEFINE_func_8012A110() /* dedup: shared engine-core @0x8012a110 (src/shared) */ -void func_8012A1BC(void) { - - extern s16 D_80120218; - extern s16 D_80120222; - extern s16 D_80120224; - extern s16 D_80120226; - extern s16 D_80120228; - extern s16 D_8012022A; - extern s16 D_8012029A; - extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; - extern s16 D_80120210; - extern s16 D_80120220; - extern s32 D_80120294; - extern s16 D_80120298; - extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; - extern Blk8 D_80126960, D_80126968; - extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; - extern s32 D_801269E4; - extern u16 D_801269E8, D_801269EA; - register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); - register u16 r6 __asm__("$6"), r7 __asm__("$7"); - register s32 r8 __asm__("$8"); - register u16 r9 __asm__("$9"), r10 __asm__("$10"); - - r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; - r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); - D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; - __asm__ __volatile__("" ::: "memory"); - D_80126960 = (*(Blk8 *)&D_80120210); - r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); - D_80126968 = (*(Blk8 *)&D_80120218); - D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; - D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; -} +DEFINE_func_8012A1BC() /* dedup: shared engine-core @0x8012A1BC (src/shared) */ DEFINE_func_8012A2F4() /* dedup: shared engine-core @0x8012a2f4 (src/shared) */ @@ -1137,49 +1097,7 @@ DEFINE_func_8012B744() /* dedup: shared engine-core @0x8012b744 (src/shared) */ -extern s32 ratan2(s32 a0, s32 a1); -extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ -extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ - -/* The 4-byte destination is a PACKED PAIR of angles held entirely in ONE saved register - * ($s4) across all three calls — that is what produces the target's - * andi $s4,$s4,0xFFFF (read of the still-uninitialized local, hoisted into the prologue) - * ... or $s4,$s4,ang<<16 -> t.hi = yaw - * ... and $s4,$s4,0xFFFF0000 / or $s4,$s4,ang&0xFFFF -> t.lo = pitch - * A `struct { s16 lo, hi; }` has align 2 -> BLKmode-ish handling: gcc spills it to the stack - * and stores it with lwl/lwr + swl/swr (54 ins, 53 mismatched). Two 16-bit BITFIELDS in a - * u32 container give the SImode, align-4 struct gcc keeps in a register. */ - -/* a0 = destination packed-angle word, a1 = "from" entity, a2 = "to" entity. - * Both entities carry 16.16 fixed-point x/y/z at +0/+4/+8; the s16 reads at +2/+6/+0xA are - * the integer halves. Returns the destination pointer — the return value is REAL: without it - * gcc stores with `sw $s4,0($s3)` (57 ins) instead of the target's - * addu $v0,$s3,$zero ; sw $s4,0($v0) (the return-value copy that the store's base coalesces onto). - * The flattened `dz` reuse at the end is also load-bearing: making the (dz*sin + dx*cos)>>12 - * temp its OWN variable gives it $a1 for the whole chain; reusing `dz` extends that allocno so - * it lands in $s5 exactly as the target does (`sra $s5,$v0,12` / `negu $a1,$s5`), and it also - * demotes dz's priority so the saved-reg order comes out $s3=out, $s4=t, $s5=dz. */ -s32 func_8012B77C(s32 out, s32 from, s32 to) { - Ang2_8012B77C_8012B77C t; - s32 dx, dy, dz; - s32 ang; - s32 r1, r2; - - dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); - dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); - dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); - - ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; - t.hi = ang; - - r1 = func_80047948(ang); - r2 = func_8004787C(ang); - dz = (dz * r1 + dx * r2) >> 12; - t.lo = ratan2(dy, -dz); - - *(Ang2_8012B77C_8012B77C *)out = t; - return out; -} +DEFINE_func_8012B77C() /* dedup: shared engine-core @0x8012B77C (src/shared) */ DEFINE_func_8012B864() /* dedup: shared engine-core @0x8012b864 (src/shared) */ @@ -1972,23 +1890,7 @@ DEFINE_func_8012EF70() /* dedup: shared engine-core @0x8012ef70 (src/shared) */ * This declaration MUST travel with the body. */ s32 aF8012EFB8(void *param_1, void *param_2) __asm__("func_8012EFB8"); -s32 aF8012EFB8(param_1, param_2) - void *param_1; - void *param_2; -{ - extern u8 D_800AF648; - s32 *m; - s32 flag; - - m = (s32 *)&D_800AF648; - gte_SetRotMatrix(m); - gte_SetTransMatrix(m); - gte_ldv0(param_1); - gte_rtps(); - gte_stsxy(param_2); - gte_stflg(&flag); - return flag; -} +DEFINE_func_8012EFB8() /* dedup: shared engine-core @0x8012EFB8 (src/shared) */ DEFINE_func_8012F038() /* dedup: shared engine-core @0x8012f038 (src/shared) */ @@ -2019,29 +1921,7 @@ DEFINE_func_8012F374() /* dedup: shared engine-core @0x8012f374 (src/shared) */ // @class: remat // @stuck: none — MATCH -extern void func_8004914C(); -extern void func_800491AC(); -extern s32 RotTransPers(s32, s32, s32*, s32*); - -s32 *func_8012F40C(s32 *param_1, s32 param_2) { - - extern u8 D_800AF648; - s32 sxy, p, flag; - - sxy = 0; - /* $a0-pinned scopes force the &D_800AF648 constant to be rematerialized - (lui/addiu) before each call instead of CSE-hoisting it into a third - callee-saved register. */ - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } - { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } - ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); - if (flag < 0) { - *param_1 = sxy = 0; - } else { - *param_1 = sxy; - } - return param_1; -} +DEFINE_func_8012F40C() /* dedup: shared engine-core @0x8012F40C (src/shared) */ DEFINE_func_8012F49C() /* dedup: shared engine-core @0x8012F49C (src/shared) */ diff --git a/src/ov_SC07_011/ov_SC07_011_jr_80131340.c b/src/ov_SC07_011/ov_SC07_011_jr_80131340.c index c16ffcde92..67d824ab97 100644 --- a/src/ov_SC07_011/ov_SC07_011_jr_80131340.c +++ b/src/ov_SC07_011/ov_SC07_011_jr_80131340.c @@ -821,25 +821,7 @@ DEFINE_func_801319E0() /* dedup: shared engine-core @0x801319e0 (src/shared) */ * - func_8012A828 is the TU's file-scope canonical (L280) `(s32, void *)`; `p` rides in * $a1 from the return of func_80131CF4, so no move is emitted. */ -extern void func_8012A828(s32 a0, void *a1); - -s32 func_80131A34(s32 a0, s32 a1) -{ - extern s32 func_80131CF4(s32); - void *p; - - p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); - if (p != 0) { - if (a1 == 0xB || a1 == 8 || a1 == 0x20) { - *(s32 *)(a0 + 0xC4) |= 4; - } else { - *(s32 *)(a0 + 0xC4) &= -5; - } - func_8012A828(a0, p); - return 1; - } - return 0; -} +DEFINE_func_80131A34() /* dedup: shared engine-core @0x80131A34 (src/shared) */ DEFINE_func_80131AC8() /* dedup: shared engine-core @0x80131ac8 (src/shared) */ @@ -948,15 +930,7 @@ extern s32 func_80131CF4(s32 a0); s32 aF80131CA8(int a0) __asm__("func_80131CA8"); -s32 aF80131CA8(int a0) -{ - s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); - if (fp != 0) { - fp(a0); - return 1; - } - return 0; -} +DEFINE_func_80131CA8() /* dedup: shared engine-core @0x80131CA8 (src/shared) */ @@ -988,37 +962,7 @@ s32 aF80131CA8(int a0) * label is still `func_80131CF4`, and the callers' `jal func_80131CF4` binds to it. * Zero header edits; body byte-identical (match_one: MATCH, 29 ins). */ -s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); - -s32 aF80131CF4(s32 *a0, s32 a1) { - s32 v0; - s32 k; - - if (a0 == 0) { - return 0; - } - goto enter; -found: - return a0[1]; -enter: - if (a0[0] == 0) { - return 0; - } - __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); - v0 = a0[0]; - do { - if (v0 == k) { - a0 = (s32 *)a0[1]; - } else { - if (v0 == a1) { - goto found; - } - a0 = (s32 *)((u8 *)a0 + 8); - } - v0 = a0[0]; - } while (v0 != 0); - return 0; -} +DEFINE_func_80131CF4() /* dedup: shared engine-core @0x80131CF4 (src/shared) */ DEFINE_func_80131D68() /* dedup: shared engine-core @0x80131d68 (src/shared) */ @@ -1477,35 +1421,7 @@ DEFINE_func_801330E0() /* dedup: shared engine-core @0x801330E0 (src/shared) */ * is a C89 error in the real TU). */ -extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); -extern void func_8012B2CC(s32 a0); -extern void func_8013339C(s16 *a0, s16 *a1); -extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); - -void func_80133298(s32 *a0) -{ - - extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ - extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ - extern s32 D_80126B60; - extern s32 D_80126B64; - s32 in[3]; - s32 out[3]; - s32 tmp[3]; - Blk32L_80133298 m; - - in[0] = D_80126B5C_w; - in[1] = D_80126B60; - in[2] = D_80126B64; - func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); - func_8012B2CC((s32)a0); - m = *(Blk32L_80133298 *)(a0[8] + 0x34); - func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); - func_8012F1A4((s32 *)&m, (s32)tmp, out); - D_80126B5C_w = out[0]; - D_80126B60 = out[1]; - D_80126B64 = out[2]; -} +DEFINE_func_80133298() /* dedup: shared engine-core @0x80133298 (src/shared) */ DEFINE_func_8013339C() /* dedup: shared engine-core @0x8013339c (src/shared) */ diff --git a/src/ov_SC07_011/ov_SC07_011_jr_80135D20.c b/src/ov_SC07_011/ov_SC07_011_jr_80135D20.c index 6323269292..e029d1d1f9 100644 --- a/src/ov_SC07_011/ov_SC07_011_jr_80135D20.c +++ b/src/ov_SC07_011/ov_SC07_011_jr_80135D20.c @@ -1274,17 +1274,7 @@ extern void func_801377B4(s32 a0, s32 a1, s32 a2); s32 aF80137614(s32 a0, s32 a1, s32 a2) __asm__("func_80137614"); -s32 aF80137614(s32 a0, s32 a1, s32 a2) -{ - s32 v1, s0; - __asm__("" : "=r"(v1) : "0"(a1)); - s0 = func_801399A8(); - if (s0 != 0) { - func_801377B4(a0, a2 & 0xD8, s0); - *(s16 *)(s0 + 0x1C) = v1; - } - return s0; -} +DEFINE_func_80137614() /* dedup: shared engine-core @0x80137614 (src/shared) */ DEFINE_func_8013767C() /* dedup: shared engine-core @0x8013767c (src/shared) */ diff --git a/src/ov_SC07_011/ov_SC07_011_jr_801380E0.c b/src/ov_SC07_011/ov_SC07_011_jr_801380E0.c index 221b11e08a..ab75c515eb 100644 --- a/src/ov_SC07_011/ov_SC07_011_jr_801380E0.c +++ b/src/ov_SC07_011/ov_SC07_011_jr_801380E0.c @@ -1064,43 +1064,7 @@ DEFINE_func_80138DB8() /* dedup: shared engine-core @0x80138db8 (src/shared) */ -extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); - -s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { - - extern s32 D_80127548[]; - extern u8 D_800D3AB4[]; - u16 *p; - - if (D_80127548[0] == 0) { - return 0; - } - p = (u16 *)(arg0 + 0x44); - if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { - p = (u16 *)(arg0 + 0x10); - if (*(s16 *)(arg0 + 4) == 8) { - p = (u16 *)(arg0 + 0x44); - } - } - if (arg1 >= 0xE0) { - arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 2; - } else if (arg1 >= 0x20) { - arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); - if (arg2 != 0) { - return 0; - } - *p = *p + 1; - } - if (arg2 != 0) { - return 0; - } - D_80127548[0] = D_80127548[0] - 1; - return D_80127548[0]; -} +DEFINE_func_80138DE0() /* dedup: shared engine-core @0x80138DE0 (src/shared) */ DEFINE_func_80138ED0() /* dedup: shared engine-core @0x80138ed0 (src/shared) */ diff --git a/src/ov_SC07_011/ov_SC07_011_jr_801457A4.c b/src/ov_SC07_011/ov_SC07_011_jr_801457A4.c index 46213ee4d8..bfb0ba29d4 100644 --- a/src/ov_SC07_011/ov_SC07_011_jr_801457A4.c +++ b/src/ov_SC07_011/ov_SC07_011_jr_801457A4.c @@ -2090,31 +2090,7 @@ void func_80149584(s32 arg0, s32 arg1, s32 arg2) { * the call-1 arg-materialization schedule order. These are __asm__ value-barriers, NOT * `register __asm__("$N")` pins. */ -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); -extern void func_8012EF70(s32, s32); - -void func_801495C4(s32 a0, s32 a1) { - s16 in[4]; - s16 result[4]; - s16 buf[4]; - s16 *pin; - s16 *m1; - s16 *m2; - s32 mtx; - - in[0] = *(u16 *)(a1 + 0x2); - in[1] = *(u16 *)(a1 + 0x6); - in[2] = *(u16 *)(a1 + 0xA); - pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); - mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); - m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); - ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); - m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); - ((void (*)(void *, void *))func_8012EF70)(m2, result); - *(s16 *)(a1 + 0x2) = result[0]; - *(s16 *)(a1 + 0x6) = result[1]; - *(s16 *)(a1 + 0xA) = result[2]; -} +DEFINE_func_801495C4() /* dedup: shared engine-core @0x801495C4 (src/shared) */ @@ -2467,52 +2443,7 @@ DEFINE_func_8014A71C() /* dedup: shared engine-core @0x8014a71c (src/shared) */ -extern s32 func_80029178(s32); - -s32 func_8014A738(void *arg0) { - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_801202A0[]; - Vec_8014A738 d; - u32 i; - Ent_801202A0 *base; - - if ((func_80029178(0x83) & 0xFF) == 0) { - return 0; - } - base = (Ent_801202A0 *)D_801202A0; - for (i = 0; i < 0x60; i++) { - if (base[i].state == 7) { - d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; - d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; - if (d.vx >= 0) { - if (d.vx < 0x40) { - goto zcheck; - } - } else { - if (-d.vx < 0x40) { - goto zcheck; - } - } - continue; - zcheck: - if (d.vz >= 0) { - if (d.vz < 0x40) { - goto found; - } - } else { - if (-d.vz < 0x40) { - goto found; - } - } - continue; - found: - return 1; - } - } - return 0; -} +DEFINE_func_8014A738() /* dedup: shared engine-core @0x8014A738 (src/shared) */ DEFINE_func_8014A830() /* dedup: shared engine-core @0x8014a830 (src/shared) */ @@ -2753,38 +2684,7 @@ DEFINE_func_8014C43C() /* dedup: shared engine-core @0x8014c43c (src/shared) */ * RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4) __asm__("func_8014C4AC"); -s32 aF8014C4AC(a0, a1, a2, a3, a4) -s32 a0; -s32 a1; -s32 a2; -s16 *a3; -u16 a4; -{ - /* block-scope: no file-scope conflict (§100) */ - extern s32 D_80126CD0; - extern u16 D_8012693A; - extern u16 D_801152B8; - u16 t; - - if (a0 == 0) { - return 0; - } - if (*(u16 *)a0 == 0) { - return 0; - } - if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { - t = *(u16 *)(a0 + 0x5C); - *(u16 *)(a0 + 0x5E) = a1; - *(u16 *)(a0 + 0x62) = a4; - *(u16 *)(a0 + 0x60) = a2; - *(u16 *)(a0 + 0x5C) = t | 1; - *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; - *(u8 *)(a0 + 0xC9) = D_8012693A; - *(u8 *)(a0 + 0xC8) = D_801152B8; - return a0; - } - return 0; -} +DEFINE_func_8014C4AC() /* dedup: shared engine-core @0x8014C4AC (src/shared) */ DEFINE_func_8014C568() /* dedup: shared engine-core @0x8014C568 (src/shared) */ @@ -3039,40 +2939,7 @@ DEFINE_func_8014D438() /* dedup: shared engine-core @0x8014d438 (src/shared) */ DEFINE_func_8014D4C0() /* dedup: shared engine-core @0x8014D4C0 (src/shared) */ -extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); -extern s32 func_8014C918(s32 a0, s32 a1); - -s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_801202A0[]; - u16 *psVar4; - u8 *puVar3; - s32 iVar2; - - psVar4 = (u16 *)D_801202A0; - while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { - puVar3 = (u8 *)psVar4 + 0x75; - if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && - *(s32 *)(puVar3 - 0x1D) != 0 && - *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { - iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( - *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); - if (iVar2 != 0) { - *(s32 *)(param_1 + 0x174) = (s32)psVar4; - puVar3[-1] = 1; - *(u16 *)(param_1 + 6) = param_3[0]; - *(u16 *)(param_1 + 0xA) = param_3[1]; - *(u16 *)(param_1 + 0xE) = param_3[2]; - *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; - return 1; - } - } - psVar4 += 0x86; - } - return 0; -} +DEFINE_func_8014D610() /* dedup: shared engine-core @0x8014D610 (src/shared) */ @@ -3549,41 +3416,7 @@ extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); * sidesteps the RETURN-axis conflict with no header edit. This line MUST travel with the body. */ s32 aF8014E5B4(s32 a0, void *a1, void *a2) __asm__("func_8014E5B4"); -s32 aF8014E5B4(s32 a0, void *a1, void *a2) -{ - - extern u8 D_801202A0[]; - register u8 *p __asm__("$17"); - register u8 *q __asm__("$16"); - u8 *e; - s32 t; - - p = D_801202A0; - if (p < p + 0x6480) { - e = p + 0x6480; - q = p + 0xE; - loop: - if (*(u16 *)p != 0) { - if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { - t = *(s32 *)(q + 0x4A); - if (t != 0) { - if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { - *(u8 **)(a0 + 0x17C) = p; - *(u16 *)(a0 + 6) = *(u16 *)(q - 8); - *(u16 *)(a0 + 0xE) = *(u16 *)q; - return 1; - } - } - } - } - p += 0x10C; - q += 0x10C; - if (p < e) { - goto loop; - } - } - return 0; -} +DEFINE_func_8014E5B4() /* dedup: shared engine-core @0x8014E5B4 (src/shared) */ diff --git a/src/ov_SC07_011/ov_SC07_011_jr_8015B950.c b/src/ov_SC07_011/ov_SC07_011_jr_8015B950.c index d265c83df0..7c79bbe0f5 100644 --- a/src/ov_SC07_011/ov_SC07_011_jr_8015B950.c +++ b/src/ov_SC07_011/ov_SC07_011_jr_8015B950.c @@ -2350,20 +2350,7 @@ void func_8015BFF4(void *a0) { * definition also match_one-MATCHes but breaks the real TU with * `conflicting types`. The s16 reads are cast at the use site. */ -extern void func_80154150(s32 a0, s32 a1); -extern void func_801553A8(s32 *a0); -extern void func_80146CA0(void *a0); - -void func_8015C030(s32 *a0, s32 a1) -{ - s32 t = *(s16 *)a1 << 7; - *(s32 *)((s32)a0 + 0x238) = 0x80000; - *(s32 *)((s32)a0 + 0x234) = t; - *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; - func_80154150((s32)a0, 0x11); - func_801553A8(a0); - func_80146CA0((void *)a0); -} +DEFINE_func_8015C030() /* dedup: shared engine-core @0x8015C030 (src/shared) */ DEFINE_func_8015C08C() /* dedup: shared engine-core @0x8015c08c (src/shared) */ diff --git a/src/ov_SC07_011/ov_SC07_011_jr_8015C32C.c b/src/ov_SC07_011/ov_SC07_011_jr_8015C32C.c index 7a40d7dc12..357ee8e734 100644 --- a/src/ov_SC07_011/ov_SC07_011_jr_8015C32C.c +++ b/src/ov_SC07_011/ov_SC07_011_jr_8015C32C.c @@ -4343,31 +4343,7 @@ s32 aF8016130C(void *a0, s32 a1) // @stuck: none — MATCH -extern void func_801599A4(void*); -extern void func_8015BDD0(s32*); -extern void func_8015BF48(s32*); -extern void func_80015954(s32, s32); - -int func_80161374(int param_1, unsigned int param_2) { - - extern int D_801152BC; - if ((param_2 == 0) || (param_2 == 0x8000)) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BDD0)(param_1); - return 1; - } - if ((param_2 & 0x4000) != 0) { - if ((D_801152BC != 0) || - (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { - ((void (*)(int))func_801599A4)(param_1); - ((void (*)(int))func_8015BF48)(param_1); - return 1; - } - ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); - return 0; - } - return 0; -} +DEFINE_func_80161374() /* dedup: shared engine-core @0x80161374 (src/shared) */ DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ @@ -4500,58 +4476,7 @@ s32 func_80161774(int param_1, u32 param_2) { DEFINE_func_80161888() /* dedup: shared engine-core @0x80161888 (src/shared) */ -extern void func_8016151C(void *a0); - - -// @class: sibling-copy (§71) + asm-label alias on the DEFINITION (§37 / §73 return-axis dodge) -// @stuck: none — match_one MATCH (24 ins) AND rtu_match MATCH (24 ins), real TU, zero fleet edits. -// -// DERIVATION (§71 sibling-first, iteration 1): -// func_80161888 @ src/ov_SC01_077/ov_SC01_077_jr_8015C32C.c:3640 is an already-MATCHED sibling -// with the identical flag-dispatch skeleton (1 / 0x4000 / 0x2000 -> 1 / 2 / 4, else 0); this -// target is that function minus the func_80161D20 consumer call. Body copied verbatim, call -// dropped. int/unsigned int spelling kept from the sibling. MATCH first try. -// -// WHY THE ASM-LABEL ALIAS (this is the only non-obvious part): -// The fleet canon declares this function inside a shared macro — -// src/shared/engine_core.h:3567, DEFINE_func_8016151C(): -// extern void func_8016191C(void *a0, s32 a1); -// but the byte-true body RETURNS s32 ($v0 = 1/2/4/0), so a plain `int func_8016191C(...)` -// definition dies with `conflicting types for 'func_8016191C'` in the real TU (rtu CC1 FAIL). -// That is §73's RETURN axis; a `void` def would DCE the $v0 constants outright. -// §73's prescribed fix is the fleet widen `extern void`->`extern s32` (T2 / R22) — exactly the -// edit already applied to the three banked siblings in this same macro block -// (engine_core.h:3546 func_8016163C -> s32, :3553 func_80161774 -> s32, :3560 func_80161888 -> int). -// The alias reaches the same place at T0 (draft-only, no tracked file touched): the C identifier -// is aF8016191C so no decl conflicts, while the emitted SYMBOL is func_8016191C. The macro's -// caller func_8016151C keeps calling the `extern void` spelling and is byte-unaffected (it -// discards the return). Verified by rtu_match, which extracts by symbol name. -// -// IF the orchestrator prefers house style over zero-touch: widen engine_core.h:3567 to -// extern s32 func_8016191C(void *a0, s32 a1); -// (batch it with any other pending §73 widens, one R22) and then the alias line can be deleted -// and the definition renamed back to `int func_8016191C(int, unsigned int)`. Byte-identical -// either way — confirmed: the same body under the plain name is match_one MATCH in isolation. - -extern void func_8014C010(int a0, int a1); - -int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); - -int aF8016191C(int param_1, unsigned int param_2) { - if (param_2 & 1) { - func_8014C010(param_1, 1); - return 1; - } - if (param_2 & 0x4000) { - func_8014C010(param_1, 1); - return 2; - } - if (param_2 & 0x2000) { - func_8014C010(param_1, 1); - return 4; - } - return 0; -} +DEFINE_func_8016191C() /* dedup: shared engine-core @0x8016191C (src/shared) */ DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197c (src/shared) */ @@ -5207,21 +5132,7 @@ void func_80162CC4(void) { extern void func_80016714(void *a0, s32 a1); void aF80162CCC(u8 *a0) __asm__("func_80162CCC"); -void aF80162CCC(u8 *a0) -{ - u8 *s0 = a0; - u16 *p = *(u16 **)(s0 + 0x20); - if (p != 0) { - s32 a1; - if (*p == 1) { - a1 = 0x84; - } else { - a1 = 0x38; - } - func_80016714(p, a1); - } - func_80016714(s0, 0x68); -} +DEFINE_func_80162CCC() /* dedup: shared engine-core @0x80162CCC (src/shared) */ DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162d28 (src/shared) */ @@ -5318,51 +5229,7 @@ void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param } -extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); - -void func_80163534(a0, a1, a2, a3, a4, a5) - s32 a0; - u16 a1; - u16 a2; - s32 a3; - u16 a4; - u16 *a5; -{ - - extern s32 D_80115100; - extern s32 D_80115200; - extern s32 D_80115204; - extern s32 D_80115208; - extern u16 D_80126B18[]; - extern u16 D_801270B0[]; - extern u16 D_801270B2; - extern u16 D_801270B4; - extern u16 D_80126B1A[]; - extern u16 D_80126B1C; - extern s32 D_80114EB0; - extern s32 D_80114EC8; - extern s32 D_8011DAF0; - extern s32 D_80115298; - extern s32 D_80126734; - s32 *p = &D_80115200; - - *p = 0; - D_80115204 = 0; - D_80115208 = 0; - - D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; - D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; - D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; - - D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; - D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; - D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; - - *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, - (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, - (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, - (s32)&D_80126734); -} +DEFINE_func_80163534() /* dedup: shared engine-core @0x80163534 (src/shared) */ DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ diff --git a/src/ov_SC07_011/ov_SC07_011_jr_8016AE5C.c b/src/ov_SC07_011/ov_SC07_011_jr_8016AE5C.c index df706b52e0..075cebac32 100644 --- a/src/ov_SC07_011/ov_SC07_011_jr_8016AE5C.c +++ b/src/ov_SC07_011/ov_SC07_011_jr_8016AE5C.c @@ -4745,37 +4745,7 @@ void func_8016F0AC(void) { * 137 siblings as a plain unit (carry the alias DECLARATION line with it — §124 trap 2). */ -extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ -extern void func_80147060(u8 *a0); -extern void func_801511A8(u8 *a0); -extern void func_80148634(void *a0); - -// @class: plumbing -// @stuck: none — MATCH (26 ins). -// Levers: (1) §42b read-global &-cast — the TU declares D_80078EB4 as s16 but the target -// loads it with `lhu`; the bare `D_80078EB4 != 0` gives `lh` (probed: closeness 1, WIDTH -// lh!=lhu), so read it as *(u16 *)&D_80078EB4. (2) both 0x1F8/0x1FC stores are s32 `sw`, -// emitted before the first jal (the 0x1FC one lands in the delay slot by sched2 — free). -// (3) the param needs no laundering: it is copied to $s0 at entry and the first call's -// `move $a0,$s0` is deleted because $a0 already holds it — plain `u8 *p` reproduces this. -// (4) §37/§124 asm-label alias — see the RECONCILE NOTE above; codegen-neutral (symbol only). - -void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); - -void aF8016F0E4(u8 *p) { - - extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ - extern u8 D_800B9A17; - *(s32 *)(p + 0x1F8) = 0; - *(s32 *)(p + 0x1FC) = 0; - func_8017196C((s32 *)p, 0); - func_80147060(p); - func_801511A8(p); - if (*(u16 *)&D_80078EB4 != 0) { - D_800B9A17 = 1; - } - func_80148634(p); -} +DEFINE_func_8016F0E4() /* dedup: shared engine-core @0x8016F0E4 (src/shared) */ DEFINE_func_8016F14C() /* dedup: shared engine-core @0x8016f14c (src/shared) */ @@ -5239,26 +5209,7 @@ DEFINE_func_8017084C() /* dedup: shared engine-core @0x8017084c (src/shared) */ -extern void func_801484B0(s32 a0, s32 a1); -extern void func_80149350(s32 arg0); -extern s32 func_8014C168(s32*, s32); -extern void func_80171928(void *a0); - -void func_801708B0(void* a0) -{ - - extern void *D_8011F738; - u16 sp10[4]; - u16 sp18[4]; - short *r; - func_801484B0((s32)&sp10, (s32)&sp18); - ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); - r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); - r[3] = sp10[0]; - r[5] = sp10[1]; - r[7] = sp10[2]; - func_80171928((void *)a0); -} +DEFINE_func_801708B0() /* dedup: shared engine-core @0x801708B0 (src/shared) */ DEFINE_func_80170928() /* dedup: shared engine-core @0x80170928 (src/shared) */ @@ -5325,38 +5276,7 @@ DEFINE_func_80170CB0() /* dedup: shared engine-core @0x80170cb0 (src/shared) */ -extern void func_801718AC(void *a0); - -void func_80170CF0(void* a0) -{ - - extern void *D_8011F738; - extern s32 D_8011F73C; - extern s32 D_8011F740; - s32 v1; - void *p; - ((void (*)(s32))D_8011F738)(a0); - v1 = *(u8 *)(a0 + 0x217); - if (v1 == 1) { - goto case_1; - } - if (v1 <= 1) { - goto done; - } - if (v1 == 2) { - goto case_2; - } - goto done; -case_1: - p = (*(void * *)&D_8011F73C); - goto call; -case_2: - p = (*(void * *)&D_8011F740); -call: - func_801718AC(p); -done: - ; -} +DEFINE_func_80170CF0() /* dedup: shared engine-core @0x80170CF0 (src/shared) */ diff --git a/src/ov_SC07_011/ov_SC07_011_jr_80171B4C.c b/src/ov_SC07_011/ov_SC07_011_jr_80171B4C.c index 12812f74c9..3191ca601d 100644 --- a/src/ov_SC07_011/ov_SC07_011_jr_80171B4C.c +++ b/src/ov_SC07_011/ov_SC07_011_jr_80171B4C.c @@ -3152,14 +3152,7 @@ DEFINE_func_80172BC8() /* dedup: shared engine-core @0x80172bc8 (src/shared) */ void func_80172C48(void) { } -extern void func_80174684(void *); -extern void func_80172CA0(void *a0); -void func_80172C50(void *a0) { - - extern s16 D_80126B30; - *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; - func_80174684((void *)func_80172CA0); -} +DEFINE_func_80172C50() /* dedup: shared engine-core @0x80172C50 (src/shared) */ @@ -3307,18 +3300,7 @@ DEFINE_func_801733CC() /* dedup: shared engine-core @0x801733cc (src/shared) */ -extern void func_801734BC(s32 a0, s32 a1); - -void func_801733FC(s32 a0, s32 a1) { - - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3E; - extern s16 D_80126B40; - func_801734BC(a0, a1); - D_80126B38 = *(struct S80126B38 *)a1; - D_80126B3E = 1; - D_80126B40 = 1; -} +DEFINE_func_801733FC() /* dedup: shared engine-core @0x801733FC (src/shared) */ DEFINE_func_80173460() /* dedup: shared engine-core @0x80173460 (src/shared) */ @@ -3442,41 +3424,7 @@ DEFINE_func_80173A28() /* dedup: shared engine-core @0x80173a28 (src/shared) */ -extern s32 func_8014C118(void*, s32, s32); -extern void func_80174684(void *); -extern void func_80173B4C(void *a0); - -void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) -{ - - extern s32 D_80126B58; - extern s32 D_80127508; - extern s16 D_80126B30; - extern struct S80126B38 D_80126B38; - extern s16 D_80126B3A; - extern s16 D_80126B3C; - extern s16 D_8011F9C8; - extern s16 D_80126938; - extern s32 D_8012750C; - s32 *s1 = &D_80126B58; - s32 v0; - - if (a2 != 0) { - D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); - } else { - D_80127508 = 0; - } - - v0 = s1[8]; - __builtin_memcpy(&D_80126B30, arg5, 8); - (*(s16 *)&D_80126B38) = a0; - D_80126B3A = a1; - D_80126B3C = *(u16 *)(v0 + 0x12); - func_80174684((void *)func_80173B4C); - D_8011F9C8 = 0; - D_80126938 = 0; - D_8012750C = 0; -} +DEFINE_func_80173A60() /* dedup: shared engine-core @0x80173A60 (src/shared) */ @@ -3698,49 +3646,7 @@ DEFINE_func_801749A8() /* dedup: shared engine-core @0x801749a8 (src/shared) */ // this defeats gcc's lhu+sext->lh combine fold so the target's lhu+sll+sra reappears; (4) inline // `iVar5 = (s16)D_80126B5E` into the f48 expression so the f28 operand load schedules first. -extern u16 D_80126B5E; -extern u16 D_80126B62; -extern u16 D_80126B66; - -extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); -extern s32 func_80012ABC(s32, s32, s32); -extern void func_80049CAC(s32 a0, s32 a1); -extern void func_8012F14C(s32 a0, s32 a1, s32 a2); - - -s32 func_801749C8(s32 param_1) -{ - Buf_c1 buf; - register s32 iVar5 __asm__("$18"); - register u32 iVar4 __asm__("$17"); - - *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); - *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); - *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); - *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); - *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); - *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); - *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); - *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); - - iVar4 = (u16)D_80126B66; - *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); - *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - func_80049CAC(param_1 + 0x18, (s32)&buf); - - buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; - buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; - buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; - buf.f20 = 0; - buf.f22 = 0; - buf.f24 = (s16)*(s32 *)(param_1 + 0x10); - ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); - - *(s32 *)(param_1 + 0x3c) = buf.f28; - *(s32 *)(param_1 + 0x40) = buf.f2a; - *(s32 *)(param_1 + 0x44) = buf.f2c; -} +DEFINE_func_801749C8() /* dedup: shared engine-core @0x801749C8 (src/shared) */ DEFINE_func_80174B6C() /* dedup: shared engine-core @0x80174b6c (src/shared) */ @@ -3968,37 +3874,7 @@ DEFINE_func_801757E0() /* dedup: shared engine-core @0x801757e0 (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_80175820(void) -{ - extern S_AE7BC_80175820_80175820 D_800AE7BC[]; - extern S_AF634_80175820_80175820 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[2]; - ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x18); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); - } -} +DEFINE_func_80175820() /* dedup: shared engine-core @0x80175820 (src/shared) */ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ @@ -4008,43 +3884,7 @@ DEFINE_func_801758FC() /* dedup: shared engine-core @0x801758FC (src/shared) */ /* size 0x14 */ /* size 0x0C */ -s32 func_801759D8(void) -{ - - extern u8 D_8011F7B1; - extern S_AE7BC_801759D8 D_800AE7BC[]; - extern S_AF634_801759D8 D_800AF634[]; - /* [T51] scoped in from file scope: a file-scope decl of these symbols constrains every - LATER function in this TU, which blocks a byte-true decl of a different type. - Declaration-only move (cookbook §103); the whole-binary byte-gate is the arbiter. */ - extern u8 D_8011F7A8; - u8 *p = (u8 *)&D_8011F7A8; - u16 *q; - u32 *ptr; - u32 old; - u32 *p2; - - if (D_8011F7B1 != 0) { - return; - } - - q = (u16 *)&(*(u16 *)&D_800B9A02); - - ptr = D_800AE7BC[*q].f0; - old = ptr[1]; - ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); - __asm__("" ::: "memory"); - - p2 = *(u32 **)(p + *q * 4 + 0x38); - *p2 = (*p2 & 0xff000000) | (old & 0xffffff); - __asm__("" ::: "memory"); - - { - s32 acc = D_800AF634[*q].g0; - s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; - D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); - } -} +DEFINE_func_801759D8() /* dedup: shared engine-core @0x801759D8 (src/shared) */ @@ -4829,41 +4669,7 @@ DEFINE_func_801777BC() /* dedup: shared engine-core @0x801777BC (src/shared) */ // @class: regalloc-order // @stuck: none — MATCH -void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { - register unsigned int uVar1 __asm__("$2"); - register unsigned int nib __asm__("$3"); - int iVar2; - register int im1 __asm__("$11"); - int p4; - register char *p __asm__("$7"); - short iVar4; - unsigned short uVar5; - register unsigned int mask __asm__("$12"); - - uVar5 = 0x100; - iVar2 = (int)param_3; - iVar4 = 0; - if (0 < iVar2) { - im1 = iVar2 - 1; - p4 = (int)param_4; - mask = ~0x100; - p = (char *)(param_1 + 0xc); - do { - uVar1 = (param_2 << 16) >> 28; - nib = uVar1; - if (((uVar1 != 0) || ((int)iVar4 == im1)) || - ((int)iVar4 == p4)) { - uVar5 = 0; - } - param_2 = param_2 << 4; - *p = (char)(nib * 8 + 8); - *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); - iVar4 = iVar4 + 1; - p = p + 0x14; - } while ((int)iVar4 < iVar2); - } - return; -} +DEFINE_func_801778A8() /* dedup: shared engine-core @0x801778A8 (src/shared) */ DEFINE_func_80177940() /* dedup: shared engine-core @0x80177940 (src/shared) */ diff --git a/src/ov_SC07_011/ov_SC07_011_o0c.c b/src/ov_SC07_011/ov_SC07_011_o0c.c index 7e9f68eae8..787bf22535 100644 --- a/src/ov_SC07_011/ov_SC07_011_o0c.c +++ b/src/ov_SC07_011/ov_SC07_011_o0c.c @@ -960,24 +960,7 @@ void func_8013BD74(void *a0, s32 a1) { } -extern void func_8013C0F8(s32 a0); - -void func_8013C08C(void *a0, void *a1) { - /* SS100 DRAFT-LOCAL type: only this function uses E_13C08C_8013C08C, so it lives in the BODY, not at - * file scope. At file scope extract_unit's preceding-decl backscan cannot carry it: the scan - * walks back over extern/comment/blank/typedef lines, and a MULTI-LINE typedef presents its - * CLOSING line first, which matches none of those prefixes. Every templated sibling therefore - * got the body without the type and the family swept 0/137 (SS94: a family 0/N is a type-carry - * failure until proven otherwise). Declared here, it is part of the unit by construction. - * NB no brace characters in this comment on purpose - extract_unit's forward brace-scan does - * not strip comments, so a brace in a comment truncates the extracted unit. */ - - void *p = a1; - - ((E_13C08C_8013C08C *)a0)->f8 = a1; - ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; - func_8013C0F8((s32)a1); -} +DEFINE_func_8013C08C() /* dedup: shared engine-core @0x8013C08C (src/shared) */ diff --git a/src/shared/engine_core.h b/src/shared/engine_core.h index b1115b1310..56ff5632b0 100644 --- a/src/shared/engine_core.h +++ b/src/shared/engine_core.h @@ -1837,6 +1837,859 @@ D_801274EC = -0x1B0; \ } +#define DEFINE_func_8017E518() \ + void func_8017E518(void) { \ + } + +#define DEFINE_func_8012A018() \ + extern void func_8012A048(void *a0, s32 a1, u8 a2); \ + void func_8012A018(s32 a0, s32 a1) \ + { \ + extern u8 D_80126948[]; \ + func_8012A048(D_80126948, a0, a1); \ + } + +#define DEFINE_func_80131CA8() \ + s32 aF80131CA8(int a0) \ + { \ + s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); \ + if (fp != 0) { \ + fp(a0); \ + return 1; \ + } \ + return 0; \ + } + +#define DEFINE_func_80172C50() \ + extern void func_80174684(void *); \ + extern void func_80172CA0(void*); \ + void func_80172C50(void *a0) { \ + extern s16 D_80126B30; \ + *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; \ + func_80174684((void *)func_80172CA0); \ + } + +#define DEFINE_func_8016BF50() \ + extern void func_80149350(s32 arg0); \ + extern void func_80015954(s32 a0, s32 a1); \ + s32 func_8016BF50(s32 param) \ + { \ + u16 buf[3]; \ + s32 arg; \ + arg = *(s32 *)(param + 0x34); \ + buf[0] = *(u16 *)(param + 0x12); \ + buf[1] = *(u16 *)(param + 0x16); \ + buf[2] = *(u16 *)(param + 0x1a); \ + ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); \ + ((void (*)(void *, s32))func_80015954)(buf, param + 4); \ + } + +#define DEFINE_func_8015C030() \ + extern void func_80154150(s32 a0, s32 a1); \ + extern void func_801553A8(s32 *a0); \ + extern void func_80146CA0(void *a0); \ + void func_8015C030(s32 *a0, s32 a1) \ + { \ + s32 t = *(s16 *)a1 << 7; \ + *(s32 *)((s32)a0 + 0x238) = 0x80000; \ + *(s32 *)((s32)a0 + 0x234) = t; \ + *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; \ + func_80154150((s32)a0, 0x11); \ + func_801553A8(a0); \ + func_80146CA0((void *)a0); \ + } + +#define DEFINE_func_80162CCC() \ + void aF80162CCC(u8 *a0) \ + { \ + u8 *s0 = a0; \ + u16 *p = *(u16 **)(s0 + 0x20); \ + if (p != 0) { \ + s32 a1; \ + if (*p == 1) { \ + a1 = 0x84; \ + } else { \ + a1 = 0x38; \ + } \ + func_80016714(p, a1); \ + } \ + func_80016714(s0, 0x68); \ + } + +#define DEFINE_func_8016191C() \ + extern void func_8016151C(void *a0); \ + extern void func_8014C010(int a0, int a1); \ + int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); \ + int aF8016191C(int param_1, unsigned int param_2) { \ + if (param_2 & 1) { \ + func_8014C010(param_1, 1); \ + return 1; \ + } \ + if (param_2 & 0x4000) { \ + func_8014C010(param_1, 1); \ + return 2; \ + } \ + if (param_2 & 0x2000) { \ + func_8014C010(param_1, 1); \ + return 4; \ + } \ + return 0; \ + } + +#define DEFINE_func_801733FC() \ + extern void func_801734BC(s32 a0, s32 a1); \ + void func_801733FC(s32 a0, s32 a1) { \ + extern struct S80126B38 D_80126B38; \ + extern s16 D_80126B3E; \ + extern s16 D_80126B40; \ + func_801734BC(a0, a1); \ + D_80126B38 = *(struct S80126B38 *)a1; \ + D_80126B3E = 1; \ + D_80126B40 = 1; \ + } + +#define DEFINE_func_80137614() \ + s32 aF80137614(s32 a0, s32 a1, s32 a2) \ + { \ + s32 v1, s0; \ + __asm__("" : "=r"(v1) : "0"(a1)); \ + s0 = func_801399A8(); \ + if (s0 != 0) { \ + func_801377B4(a0, a2 & 0xD8, s0); \ + *(s16 *)(s0 + 0x1C) = v1; \ + } \ + return s0; \ + } + +#define DEFINE_func_8016F0E4() \ + extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ \ + extern void func_80147060(u8 *a0); \ + extern void func_801511A8(u8 *a0); \ + extern void func_80148634(void *a0); \ + void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); \ + void aF8016F0E4(u8 *p) { \ + extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ \ + extern u8 D_800B9A17; \ + *(s32 *)(p + 0x1F8) = 0; \ + *(s32 *)(p + 0x1FC) = 0; \ + func_8017196C((s32 *)p, 0); \ + func_80147060(p); \ + func_801511A8(p); \ + if (*(u16 *)&D_80078EB4 != 0) { \ + D_800B9A17 = 1; \ + } \ + func_80148634(p); \ + } + +#define DEFINE_func_8013C08C() \ + extern void func_8013C0F8(s32 a0); \ + void func_8013C08C(void *a0, void *a1) { \ + void *p = a1; \ + ((E_13C08C_8013C08C *)a0)->f8 = a1; \ + ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; \ + func_8013C0F8((s32)a1); \ + } + +#define DEFINE_func_80131CF4() \ + s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); \ + s32 aF80131CF4(s32 *a0, s32 a1) { \ + s32 v0; \ + s32 k; \ + if (a0 == 0) { \ + return 0; \ + } \ + goto enter; \ + found: \ + return a0[1]; \ + enter: \ + if (a0[0] == 0) { \ + return 0; \ + } \ + __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); \ + v0 = a0[0]; \ + do { \ + if (v0 == k) { \ + a0 = (s32 *)a0[1]; \ + } else { \ + if (v0 == a1) { \ + goto found; \ + } \ + a0 = (s32 *)((u8 *)a0 + 8); \ + } \ + v0 = a0[0]; \ + } while (v0 != 0); \ + return 0; \ + } + +#define DEFINE_func_8016706C() \ + extern void func_80146C3C(void); \ + void func_8016706C(s32 param_1) \ + { \ + extern s32 D_8011D030; \ + unsigned short *puVar1; \ + short iVar2; \ + iVar2 = 0; \ + puVar1 = ((unsigned short *)&D_8011D030); \ + do { \ + if ((unsigned int)*puVar1 == ((short)param_1)) { \ + ((void(*)(unsigned short *))func_80146C3C)(puVar1); \ + } \ + iVar2 = iVar2 + 1; \ + puVar1 = puVar1 + 0x2c; \ + } while (iVar2 < 0x1e); \ + } + +#define DEFINE_func_801708B0() \ + extern void func_801484B0(s32 a0, s32 a1); \ + extern void func_80149350(s32 arg0); \ + extern s32 func_8014C168(s32*, s32); \ + extern void func_80171928(void *a0); \ + void func_801708B0(void* a0) \ + { \ + extern void *D_8011F738; \ + u16 sp10[4]; \ + u16 sp18[4]; \ + short *r; \ + func_801484B0((s32)&sp10, (s32)&sp18); \ + ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); \ + r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); \ + r[3] = sp10[0]; \ + r[5] = sp10[1]; \ + r[7] = sp10[2]; \ + func_80171928((void *)a0); \ + } + +#define DEFINE_func_80170CF0() \ + extern void func_801718AC(void *a0); \ + void func_80170CF0(void* a0) \ + { \ + extern void *D_8011F738; \ + extern s32 D_8011F73C; \ + extern s32 D_8011F740; \ + s32 v1; \ + void *p; \ + ((void (*)(s32))D_8011F738)(a0); \ + v1 = *(u8 *)(a0 + 0x217); \ + if (v1 == 1) { \ + goto case_1; \ + } \ + if (v1 <= 1) { \ + goto done; \ + } \ + if (v1 == 2) { \ + goto case_2; \ + } \ + goto done; \ + case_1: \ + p = (*(void * *)&D_8011F73C); \ + goto call; \ + case_2: \ + p = (*(void * *)&D_8011F740); \ + call: \ + func_801718AC(p); \ + done: \ + ; \ + } + +#define DEFINE_func_8012EFB8() \ + s32 aF8012EFB8(param_1, param_2) \ + void *param_1; \ + void *param_2; \ + { \ + extern u8 D_800AF648; \ + s32 *m; \ + s32 flag; \ + m = (s32 *)&D_800AF648; \ + gte_SetRotMatrix(m); \ + gte_SetTransMatrix(m); \ + gte_ldv0(param_1); \ + gte_rtps(); \ + gte_stsxy(param_2); \ + gte_stflg(&flag); \ + return flag; \ + } + +#define DEFINE_func_801495C4() \ + extern void func_8014964C(s32 param_1, s32 param_2); \ + extern void func_8012F14C(s32 a0, s32 a1, s32 a2); \ + extern void func_8012EF70(s32, s32); \ + void func_801495C4(s32 a0, s32 a1) { \ + s16 in[4]; \ + s16 result[4]; \ + s16 buf[4]; \ + s16 *pin; \ + s16 *m1; \ + s16 *m2; \ + s32 mtx; \ + in[0] = *(u16 *)(a1 + 0x2); \ + in[1] = *(u16 *)(a1 + 0x6); \ + in[2] = *(u16 *)(a1 + 0xA); \ + pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); \ + mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); \ + m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); \ + ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); \ + m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); \ + ((void (*)(void *, void *))func_8012EF70)(m2, result); \ + *(s16 *)(a1 + 0x2) = result[0]; \ + *(s16 *)(a1 + 0x6) = result[1]; \ + *(s16 *)(a1 + 0xA) = result[2]; \ + } + +#define DEFINE_func_8012F40C() \ + extern void func_8004914C(); \ + extern void func_800491AC(); \ + extern s32 RotTransPers(s32, s32, s32*, s32*); \ + s32 *func_8012F40C(s32 *param_1, s32 param_2) { \ + extern u8 D_800AF648; \ + s32 sxy, p, flag; \ + sxy = 0; \ + { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } \ + { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } \ + ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); \ + if (flag < 0) { \ + *param_1 = sxy = 0; \ + } else { \ + *param_1 = sxy; \ + } \ + return param_1; \ + } + +#define DEFINE_func_80131A34() \ + extern void func_8012A828(s32 a0, void *a1); \ + s32 func_80131A34(s32 a0, s32 a1) \ + { \ + extern s32 func_80131CF4(s32); \ + void *p; \ + p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); \ + if (p != 0) { \ + if (a1 == 0xB || a1 == 8 || a1 == 0x20) { \ + *(s32 *)(a0 + 0xC4) |= 4; \ + } else { \ + *(s32 *)(a0 + 0xC4) &= -5; \ + } \ + func_8012A828(a0, p); \ + return 1; \ + } \ + return 0; \ + } + +#define DEFINE_func_801778A8() \ + void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { \ + register unsigned int uVar1 __asm__("$2"); \ + register unsigned int nib __asm__("$3"); \ + int iVar2; \ + register int im1 __asm__("$11"); \ + int p4; \ + register char *p __asm__("$7"); \ + short iVar4; \ + unsigned short uVar5; \ + register unsigned int mask __asm__("$12"); \ + uVar5 = 0x100; \ + iVar2 = (int)param_3; \ + iVar4 = 0; \ + if (0 < iVar2) { \ + im1 = iVar2 - 1; \ + p4 = (int)param_4; \ + mask = ~0x100; \ + p = (char *)(param_1 + 0xc); \ + do { \ + uVar1 = (param_2 << 16) >> 28; \ + nib = uVar1; \ + if (((uVar1 != 0) || ((int)iVar4 == im1)) || \ + ((int)iVar4 == p4)) { \ + uVar5 = 0; \ + } \ + param_2 = param_2 << 4; \ + *p = (char)(nib * 8 + 8); \ + *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); \ + iVar4 = iVar4 + 1; \ + p = p + 0x14; \ + } while ((int)iVar4 < iVar2); \ + } \ + return; \ + } + +#define DEFINE_func_80161374() \ + extern void func_801599A4(void*); \ + extern void func_8015BDD0(s32*); \ + extern void func_8015BF48(s32*); \ + extern void func_80015954(s32, s32); \ + int func_80161374(int param_1, unsigned int param_2) { \ + extern int D_801152BC; \ + if ((param_2 == 0) || (param_2 == 0x8000)) { \ + ((void (*)(int))func_801599A4)(param_1); \ + ((void (*)(int))func_8015BDD0)(param_1); \ + return 1; \ + } \ + if ((param_2 & 0x4000) != 0) { \ + if ((D_801152BC != 0) || \ + (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { \ + ((void (*)(int))func_801599A4)(param_1); \ + ((void (*)(int))func_8015BF48)(param_1); \ + return 1; \ + } \ + ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); \ + return 0; \ + } \ + return 0; \ + } + +#define DEFINE_func_8014C4AC() \ + s32 aF8014C4AC(a0, a1, a2, a3, a4) \ + s32 a0; \ + s32 a1; \ + s32 a2; \ + s16 *a3; \ + u16 a4; \ + { \ + extern s32 D_80126CD0; \ + extern u16 D_8012693A; \ + extern u16 D_801152B8; \ + u16 t; \ + if (a0 == 0) { \ + return 0; \ + } \ + if (*(u16 *)a0 == 0) { \ + return 0; \ + } \ + if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { \ + t = *(u16 *)(a0 + 0x5C); \ + *(u16 *)(a0 + 0x5E) = a1; \ + *(u16 *)(a0 + 0x62) = a4; \ + *(u16 *)(a0 + 0x60) = a2; \ + *(u16 *)(a0 + 0x5C) = t | 1; \ + *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; \ + *(u8 *)(a0 + 0xC9) = D_8012693A; \ + *(u8 *)(a0 + 0xC8) = D_801152B8; \ + return a0; \ + } \ + return 0; \ + } + +#define DEFINE_func_801376E8() \ + void *aF801376E8(int a0, int a1) \ + { \ + extern s32 D_801269F0; \ + extern u8 D_801269FD; \ + extern u16 D_80126A14[]; \ + extern s16 D_80126A1C; \ + extern s16 D_80126A20; \ + extern s16 D_80126A22; \ + extern s16 D_80126A24; \ + extern u16 D_80126A26; \ + u16 *p = (u16 *)a1; \ + s32 obj = (s32)&D_801269F0; \ + func_801377B4(a0, 0x6200, obj); \ + D_80126A1C = 0x1C; \ + D_801269FD = 0; \ + if (p != 0) { \ + D_80126A14[0] = p[0]; \ + D_80126A14[1] = p[1]; \ + } \ + func_80139BE0(obj); \ + D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); \ + D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); \ + return (void *)obj; \ + } + +#define DEFINE_func_80175820() \ + s32 func_80175820(void) \ + { \ + extern s16 D_800B9A02; \ + extern S_AE7BC_80175820_80175820 D_800AE7BC[]; \ + extern S_AF634_80175820_80175820 D_800AF634[]; \ + extern u8 D_8011F7A8; \ + u8 *p = (u8 *)&D_8011F7A8; \ + u16 *q; \ + u32 *ptr; \ + u32 old; \ + u32 *p2; \ + q = (u16 *)&(*(u16 *)&D_800B9A02); \ + ptr = D_800AE7BC[*q].f0; \ + old = ptr[2]; \ + ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); \ + __asm__("" ::: "memory"); \ + p2 = *(u32 **)(p + *q * 4 + 0x18); \ + *p2 = (*p2 & 0xff000000) | (old & 0xffffff); \ + __asm__("" ::: "memory"); \ + { \ + s32 acc = D_800AF634[*q].g0; \ + s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; \ + D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); \ + } \ + } + +#define DEFINE_func_801759D8() \ + s32 func_801759D8(void) \ + { \ + extern u8 D_8011F7B1; \ + extern s16 D_800B9A02; \ + extern S_AE7BC_801759D8 D_800AE7BC[]; \ + extern S_AF634_801759D8 D_800AF634[]; \ + extern u8 D_8011F7A8; \ + u8 *p = (u8 *)&D_8011F7A8; \ + u16 *q; \ + u32 *ptr; \ + u32 old; \ + u32 *p2; \ + if (D_8011F7B1 != 0) { \ + return; \ + } \ + q = (u16 *)&(*(u16 *)&D_800B9A02); \ + ptr = D_800AE7BC[*q].f0; \ + old = ptr[1]; \ + ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); \ + __asm__("" ::: "memory"); \ + p2 = *(u32 **)(p + *q * 4 + 0x38); \ + *p2 = (*p2 & 0xff000000) | (old & 0xffffff); \ + __asm__("" ::: "memory"); \ + { \ + s32 acc = D_800AF634[*q].g0; \ + s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; \ + D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); \ + } \ + } + +#define DEFINE_func_8012B77C() \ + extern s32 ratan2(s32 a0, s32 a1); \ + extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ \ + extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ \ + s32 func_8012B77C(s32 out, s32 from, s32 to) { \ + Ang2_8012B77C_8012B77C t; \ + s32 dx, dy, dz; \ + s32 ang; \ + s32 r1, r2; \ + dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); \ + dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); \ + dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); \ + ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; \ + t.hi = ang; \ + r1 = func_80047948(ang); \ + r2 = func_8004787C(ang); \ + dz = (dz * r1 + dx * r2) >> 12; \ + t.lo = ratan2(dy, -dz); \ + *(Ang2_8012B77C_8012B77C *)out = t; \ + return out; \ + } + +#define DEFINE_func_8014E5B4() \ + s32 aF8014E5B4(s32 a0, void *a1, void *a2) \ + { \ + extern u8 D_801202A0[]; \ + register u8 *p __asm__("$17"); \ + register u8 *q __asm__("$16"); \ + u8 *e; \ + s32 t; \ + p = D_801202A0; \ + if (p < p + 0x6480) { \ + e = p + 0x6480; \ + q = p + 0xE; \ + loop: \ + if (*(u16 *)p != 0) { \ + if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { \ + t = *(s32 *)(q + 0x4A); \ + if (t != 0) { \ + if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { \ + *(u8 **)(a0 + 0x17C) = p; \ + *(u16 *)(a0 + 6) = *(u16 *)(q - 8); \ + *(u16 *)(a0 + 0xE) = *(u16 *)q; \ + return 1; \ + } \ + } \ + } \ + } \ + p += 0x10C; \ + q += 0x10C; \ + if (p < e) { \ + goto loop; \ + } \ + } \ + return 0; \ + } + +#define DEFINE_func_80173A60() \ + extern s32 func_8014C118(void*, s32, s32); \ + extern void func_80174684(void *); \ + extern void func_80173B4C(void*); \ + void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { \ + extern s32 D_80126B58; \ + extern s32 D_80127508; \ + extern s16 D_80126B30; \ + extern struct S80126B38 D_80126B38; \ + extern s16 D_80126B3A; \ + extern s16 D_80126B3C; \ + extern s16 D_8011F9C8; \ + extern s16 D_80126938; \ + extern s32 D_8012750C; \ + s32 *s1 = &D_80126B58; \ + s32 v0; \ + if (a2 != 0) { \ + D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); \ + } else { \ + D_80127508 = 0; \ + } \ + v0 = s1[8]; \ + __builtin_memcpy(&D_80126B30, arg5, 8); \ + (*(s16 *)&D_80126B38) = a0; \ + D_80126B3A = a1; \ + D_80126B3C = *(u16 *)(v0 + 0x12); \ + func_80174684((void *)func_80173B4C); \ + D_8011F9C8 = 0; \ + D_80126938 = 0; \ + D_8012750C = 0; \ + } + +#define DEFINE_func_80138DE0() \ + extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); \ + s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { \ + extern s32 D_80127548[]; \ + extern u8 D_800D3AB4[]; \ + u16 *p; \ + if (D_80127548[0] == 0) { \ + return 0; \ + } \ + p = (u16 *)(arg0 + 0x44); \ + if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { \ + p = (u16 *)(arg0 + 0x10); \ + if (*(s16 *)(arg0 + 4) == 8) { \ + p = (u16 *)(arg0 + 0x44); \ + } \ + } \ + if (arg1 >= 0xE0) { \ + arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); \ + if (arg2 != 0) { \ + return 0; \ + } \ + *p = *p + 2; \ + } else if (arg1 >= 0x20) { \ + arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); \ + if (arg2 != 0) { \ + return 0; \ + } \ + *p = *p + 1; \ + } \ + if (arg2 != 0) { \ + return 0; \ + } \ + D_80127548[0] = D_80127548[0] - 1; \ + return D_80127548[0]; \ + } + +#define DEFINE_func_8014A738() \ + extern s32 func_80029178(s32); \ + s32 func_8014A738(void *arg0) { \ + extern u8 D_801202A0[]; \ + Vec_8014A738 d; \ + u32 i; \ + Ent_801202A0 *base; \ + if ((func_80029178(0x83) & 0xFF) == 0) { \ + return 0; \ + } \ + base = (Ent_801202A0 *)D_801202A0; \ + for (i = 0; i < 0x60; i++) { \ + if (base[i].state == 7) { \ + d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; \ + d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; \ + if (d.vx >= 0) { \ + if (d.vx < 0x40) { \ + goto zcheck; \ + } \ + } else { \ + if (-d.vx < 0x40) { \ + goto zcheck; \ + } \ + } \ + continue; \ + zcheck: \ + if (d.vz >= 0) { \ + if (d.vz < 0x40) { \ + goto found; \ + } \ + } else { \ + if (-d.vz < 0x40) { \ + goto found; \ + } \ + } \ + continue; \ + found: \ + return 1; \ + } \ + } \ + return 0; \ + } + +#define DEFINE_func_80133298() \ + extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); \ + extern void func_8012B2CC(s32 a0); \ + extern void func_8013339C(s16 *a0, s16 *a1); \ + extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); \ + void func_80133298(s32 *a0) \ + { \ + extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ \ + extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ \ + extern s32 D_80126B60; \ + extern s32 D_80126B64; \ + s32 in[3]; \ + s32 out[3]; \ + s32 tmp[3]; \ + Blk32L_80133298 m; \ + in[0] = D_80126B5C_w; \ + in[1] = D_80126B60; \ + in[2] = D_80126B64; \ + func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); \ + func_8012B2CC((s32)a0); \ + m = *(Blk32L_80133298 *)(a0[8] + 0x34); \ + func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); \ + func_8012F1A4((s32 *)&m, (s32)tmp, out); \ + D_80126B5C_w = out[0]; \ + D_80126B60 = out[1]; \ + D_80126B64 = out[2]; \ + } + +#define DEFINE_func_8014D610() \ + extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); \ + extern s32 func_8014C918(s32 a0, s32 a1); \ + s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { \ + extern u8 D_801202A0[]; \ + u16 *psVar4; \ + u8 *puVar3; \ + s32 iVar2; \ + psVar4 = (u16 *)D_801202A0; \ + while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { \ + puVar3 = (u8 *)psVar4 + 0x75; \ + if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && \ + *(s32 *)(puVar3 - 0x1D) != 0 && \ + *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { \ + iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( \ + *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); \ + if (iVar2 != 0) { \ + *(s32 *)(param_1 + 0x174) = (s32)psVar4; \ + puVar3[-1] = 1; \ + *(u16 *)(param_1 + 6) = param_3[0]; \ + *(u16 *)(param_1 + 0xA) = param_3[1]; \ + *(u16 *)(param_1 + 0xE) = param_3[2]; \ + *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; \ + return 1; \ + } \ + } \ + psVar4 += 0x86; \ + } \ + return 0; \ + } + +#define DEFINE_func_80163534() \ + extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); \ + void func_80163534(a0, a1, a2, a3, a4, a5) \ + s32 a0; \ + u16 a1; \ + u16 a2; \ + s32 a3; \ + u16 a4; \ + u16 *a5; \ + { \ + extern s32 D_80115100; \ + extern s32 D_80115200; \ + extern s32 D_80115204; \ + extern s32 D_80115208; \ + extern u16 D_80126B18[]; \ + extern u16 D_801270B0[]; \ + extern u16 D_801270B2; \ + extern u16 D_801270B4; \ + extern u16 D_80126B1A[]; \ + extern u16 D_80126B1C; \ + extern s32 D_80114EB0; \ + extern s32 D_80114EC8; \ + extern s32 D_8011DAF0; \ + extern s32 D_80115298; \ + extern s32 D_80126734; \ + s32 *p = &D_80115200; \ + *p = 0; \ + D_80115204 = 0; \ + D_80115208 = 0; \ + D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; \ + D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; \ + D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; \ + D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; \ + D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; \ + D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; \ + *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, \ + (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, \ + (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, \ + (s32)&D_80126734); \ + } + +#define DEFINE_func_8012A1BC() \ + void func_8012A1BC(void) { \ + extern s16 D_80120218; \ + extern s16 D_80120222; \ + extern s16 D_80120224; \ + extern s16 D_80120226; \ + extern s16 D_80120228; \ + extern s16 D_8012022A; \ + extern s16 D_8012029A; \ + extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; \ + extern s16 D_80120210; \ + extern s16 D_80120220; \ + extern s32 D_80120294; \ + extern s16 D_80120298; \ + extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; \ + extern Blk8 D_80126960, D_80126968; \ + extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; \ + extern s32 D_801269E4; \ + extern u16 D_801269E8, D_801269EA; \ + register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); \ + register u16 r6 __asm__("$6"), r7 __asm__("$7"); \ + register s32 r8 __asm__("$8"); \ + register u16 r9 __asm__("$9"), r10 __asm__("$10"); \ + r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; \ + r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); \ + D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; \ + __asm__ __volatile__("" ::: "memory"); \ + D_80126960 = (*(Blk8 *)&D_80120210); \ + r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); \ + D_80126968 = (*(Blk8 *)&D_80120218); \ + D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; \ + D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; \ + } + +#define DEFINE_func_801749C8() \ + extern u16 D_80126B5E; \ + extern u16 D_80126B62; \ + extern u16 D_80126B66; \ + extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); \ + extern s32 func_80012ABC(s32, s32, s32); \ + extern void func_80049CAC(s32 a0, s32 a1); \ + extern void func_8012F14C(s32 a0, s32 a1, s32 a2); \ + s32 func_801749C8(s32 param_1) \ + { \ + Buf_c1 buf; \ + register s32 iVar5 __asm__("$18"); \ + register u32 iVar4 __asm__("$17"); \ + *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); \ + *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); \ + *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); \ + *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); \ + *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); \ + *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); \ + *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); \ + *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); \ + iVar4 = (u16)D_80126B66; \ + *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); \ + *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; \ + *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; \ + func_80049CAC(param_1 + 0x18, (s32)&buf); \ + buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; \ + buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; \ + buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; \ + buf.f20 = 0; \ + buf.f22 = 0; \ + buf.f24 = (s16)*(s32 *)(param_1 + 0x10); \ + ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); \ + *(s32 *)(param_1 + 0x3c) = buf.f28; \ + *(s32 *)(param_1 + 0x40) = buf.f2a; \ + *(s32 *)(param_1 + 0x44) = buf.f2c; \ + } + #endif #define DEFINE_func_80128EA8() \ @@ -33079,4 +33932,857 @@ D_801274EC = -0x1B0; \ } +#define DEFINE_func_8017E518() \ + void func_8017E518(void) { \ + } + +#define DEFINE_func_8012A018() \ + extern void func_8012A048(void *a0, s32 a1, u8 a2); \ + void func_8012A018(s32 a0, s32 a1) \ + { \ + extern u8 D_80126948[]; \ + func_8012A048(D_80126948, a0, a1); \ + } + +#define DEFINE_func_80131CA8() \ + s32 aF80131CA8(int a0) \ + { \ + s32 (*fp)(int) = (s32 (*)(int))func_80131CF4(*(s32 *)((u8 *)a0 + 0xBC)); \ + if (fp != 0) { \ + fp(a0); \ + return 1; \ + } \ + return 0; \ + } + +#define DEFINE_func_80172C50() \ + extern void func_80174684(void *); \ + extern void func_80172CA0(void*); \ + void func_80172C50(void *a0) { \ + extern s16 D_80126B30; \ + *(struct S8_80172780 *)&D_80126B30 = *(struct S8_80172780 *)a0; \ + func_80174684((void *)func_80172CA0); \ + } + +#define DEFINE_func_8016BF50() \ + extern void func_80149350(s32 arg0); \ + extern void func_80015954(s32 a0, s32 a1); \ + s32 func_8016BF50(s32 param) \ + { \ + u16 buf[3]; \ + s32 arg; \ + arg = *(s32 *)(param + 0x34); \ + buf[0] = *(u16 *)(param + 0x12); \ + buf[1] = *(u16 *)(param + 0x16); \ + buf[2] = *(u16 *)(param + 0x1a); \ + ((void (*)(s32, void *, void *))func_80149350)(arg, buf, buf); \ + ((void (*)(void *, s32))func_80015954)(buf, param + 4); \ + } + +#define DEFINE_func_8015C030() \ + extern void func_80154150(s32 a0, s32 a1); \ + extern void func_801553A8(s32 *a0); \ + extern void func_80146CA0(void *a0); \ + void func_8015C030(s32 *a0, s32 a1) \ + { \ + s32 t = *(s16 *)a1 << 7; \ + *(s32 *)((s32)a0 + 0x238) = 0x80000; \ + *(s32 *)((s32)a0 + 0x234) = t; \ + *(s32 *)((s32)a0 + 0x23C) = *(s16 *)(a1 + 4) << 7; \ + func_80154150((s32)a0, 0x11); \ + func_801553A8(a0); \ + func_80146CA0((void *)a0); \ + } + +#define DEFINE_func_80162CCC() \ + void aF80162CCC(u8 *a0) \ + { \ + u8 *s0 = a0; \ + u16 *p = *(u16 **)(s0 + 0x20); \ + if (p != 0) { \ + s32 a1; \ + if (*p == 1) { \ + a1 = 0x84; \ + } else { \ + a1 = 0x38; \ + } \ + func_80016714(p, a1); \ + } \ + func_80016714(s0, 0x68); \ + } + +#define DEFINE_func_8016191C() \ + extern void func_8016151C(void *a0); \ + extern void func_8014C010(int a0, int a1); \ + int aF8016191C(int param_1, unsigned int param_2) __asm__("func_8016191C"); \ + int aF8016191C(int param_1, unsigned int param_2) { \ + if (param_2 & 1) { \ + func_8014C010(param_1, 1); \ + return 1; \ + } \ + if (param_2 & 0x4000) { \ + func_8014C010(param_1, 1); \ + return 2; \ + } \ + if (param_2 & 0x2000) { \ + func_8014C010(param_1, 1); \ + return 4; \ + } \ + return 0; \ + } + +#define DEFINE_func_801733FC() \ + extern void func_801734BC(s32 a0, s32 a1); \ + void func_801733FC(s32 a0, s32 a1) { \ + extern struct S80126B38 D_80126B38; \ + extern s16 D_80126B3E; \ + extern s16 D_80126B40; \ + func_801734BC(a0, a1); \ + D_80126B38 = *(struct S80126B38 *)a1; \ + D_80126B3E = 1; \ + D_80126B40 = 1; \ + } + +#define DEFINE_func_80137614() \ + s32 aF80137614(s32 a0, s32 a1, s32 a2) \ + { \ + s32 v1, s0; \ + __asm__("" : "=r"(v1) : "0"(a1)); \ + s0 = func_801399A8(); \ + if (s0 != 0) { \ + func_801377B4(a0, a2 & 0xD8, s0); \ + *(s16 *)(s0 + 0x1C) = v1; \ + } \ + return s0; \ + } + +#define DEFINE_func_8016F0E4() \ + extern void func_8017196C(s32 *a0, s8 a1); /* == DEFINE_func_8017196C's own signature */ \ + extern void func_80147060(u8 *a0); \ + extern void func_801511A8(u8 *a0); \ + extern void func_80148634(void *a0); \ + void aF8016F0E4(u8 *p) __asm__("func_8016F0E4"); \ + void aF8016F0E4(u8 *p) { \ + extern s16 D_80078EB4; /* fleet-canonical spelling; see the &-cast below */ \ + extern u8 D_800B9A17; \ + *(s32 *)(p + 0x1F8) = 0; \ + *(s32 *)(p + 0x1FC) = 0; \ + func_8017196C((s32 *)p, 0); \ + func_80147060(p); \ + func_801511A8(p); \ + if (*(u16 *)&D_80078EB4 != 0) { \ + D_800B9A17 = 1; \ + } \ + func_80148634(p); \ + } + +#define DEFINE_func_8013C08C() \ + extern void func_8013C0F8(s32 a0); \ + void func_8013C08C(void *a0, void *a1) { \ + void *p = a1; \ + ((E_13C08C_8013C08C *)a0)->f8 = a1; \ + ((E_13C08C_8013C08C *)a0)->fC = (u8 *)p + 0x14; \ + func_8013C0F8((s32)a1); \ + } + +#define DEFINE_func_80131CF4() \ + s32 aF80131CF4(s32 *a0, s32 a1) __asm__("func_80131CF4"); \ + s32 aF80131CF4(s32 *a0, s32 a1) { \ + s32 v0; \ + s32 k; \ + if (a0 == 0) { \ + return 0; \ + } \ + goto enter; \ + found: \ + return a0[1]; \ + enter: \ + if (a0[0] == 0) { \ + return 0; \ + } \ + __asm__ __volatile__("" : "=r"(k) : "0"(0xD) : "memory"); \ + v0 = a0[0]; \ + do { \ + if (v0 == k) { \ + a0 = (s32 *)a0[1]; \ + } else { \ + if (v0 == a1) { \ + goto found; \ + } \ + a0 = (s32 *)((u8 *)a0 + 8); \ + } \ + v0 = a0[0]; \ + } while (v0 != 0); \ + return 0; \ + } + +#define DEFINE_func_8016706C() \ + extern void func_80146C3C(void); \ + void func_8016706C(s32 param_1) \ + { \ + extern s32 D_8011D030; \ + unsigned short *puVar1; \ + short iVar2; \ + iVar2 = 0; \ + puVar1 = ((unsigned short *)&D_8011D030); \ + do { \ + if ((unsigned int)*puVar1 == ((short)param_1)) { \ + ((void(*)(unsigned short *))func_80146C3C)(puVar1); \ + } \ + iVar2 = iVar2 + 1; \ + puVar1 = puVar1 + 0x2c; \ + } while (iVar2 < 0x1e); \ + } + +#define DEFINE_func_801708B0() \ + extern void func_801484B0(s32 a0, s32 a1); \ + extern void func_80149350(s32 arg0); \ + extern s32 func_8014C168(s32*, s32); \ + extern void func_80171928(void *a0); \ + void func_801708B0(void* a0) \ + { \ + extern void *D_8011F738; \ + u16 sp10[4]; \ + u16 sp18[4]; \ + short *r; \ + func_801484B0((s32)&sp10, (s32)&sp18); \ + ((void (*)(s32, void *, void *))func_80149350)((s32)a0, &sp10, &sp10); \ + r = (short *)((s32 (*)(s32, s32))func_8014C168)((s32)a0, (*(s32 *)&D_8011F738)); \ + r[3] = sp10[0]; \ + r[5] = sp10[1]; \ + r[7] = sp10[2]; \ + func_80171928((void *)a0); \ + } + +#define DEFINE_func_80170CF0() \ + extern void func_801718AC(void *a0); \ + void func_80170CF0(void* a0) \ + { \ + extern void *D_8011F738; \ + extern s32 D_8011F73C; \ + extern s32 D_8011F740; \ + s32 v1; \ + void *p; \ + ((void (*)(s32))D_8011F738)(a0); \ + v1 = *(u8 *)(a0 + 0x217); \ + if (v1 == 1) { \ + goto case_1; \ + } \ + if (v1 <= 1) { \ + goto done; \ + } \ + if (v1 == 2) { \ + goto case_2; \ + } \ + goto done; \ + case_1: \ + p = (*(void * *)&D_8011F73C); \ + goto call; \ + case_2: \ + p = (*(void * *)&D_8011F740); \ + call: \ + func_801718AC(p); \ + done: \ + ; \ + } + +#define DEFINE_func_8012EFB8() \ + s32 aF8012EFB8(param_1, param_2) \ + void *param_1; \ + void *param_2; \ + { \ + extern u8 D_800AF648; \ + s32 *m; \ + s32 flag; \ + m = (s32 *)&D_800AF648; \ + gte_SetRotMatrix(m); \ + gte_SetTransMatrix(m); \ + gte_ldv0(param_1); \ + gte_rtps(); \ + gte_stsxy(param_2); \ + gte_stflg(&flag); \ + return flag; \ + } + +#define DEFINE_func_801495C4() \ + extern void func_8014964C(s32 param_1, s32 param_2); \ + extern void func_8012F14C(s32 a0, s32 a1, s32 a2); \ + extern void func_8012EF70(s32, s32); \ + void func_801495C4(s32 a0, s32 a1) { \ + s16 in[4]; \ + s16 result[4]; \ + s16 buf[4]; \ + s16 *pin; \ + s16 *m1; \ + s16 *m2; \ + s32 mtx; \ + in[0] = *(u16 *)(a1 + 0x2); \ + in[1] = *(u16 *)(a1 + 0x6); \ + in[2] = *(u16 *)(a1 + 0xA); \ + pin = in; __asm__ __volatile__("" : "=r"(pin) : "0"(pin)); \ + mtx = *(s32 *)(a0 + 0x20); __asm__ __volatile__("" : "=r"(mtx) : "0"(mtx)); \ + m1 = buf; __asm__ __volatile__("" : "=r"(m1) : "0"(m1)); \ + ((void (*)(s32, void *, void *))func_8012F14C)(mtx + 0x34, pin, m1); \ + m2 = buf; __asm__ __volatile__("" : "=r"(m2) : "0"(m2)); \ + ((void (*)(void *, void *))func_8012EF70)(m2, result); \ + *(s16 *)(a1 + 0x2) = result[0]; \ + *(s16 *)(a1 + 0x6) = result[1]; \ + *(s16 *)(a1 + 0xA) = result[2]; \ + } + +#define DEFINE_func_8012F40C() \ + extern void func_8004914C(); \ + extern void func_800491AC(); \ + extern s32 RotTransPers(s32, s32, s32*, s32*); \ + s32 *func_8012F40C(s32 *param_1, s32 param_2) { \ + extern u8 D_800AF648; \ + s32 sxy, p, flag; \ + sxy = 0; \ + { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_8004914C(r4); } \ + { register void *r4 __asm__("$4"); r4 = &D_800AF648; func_800491AC(r4); } \ + ((s32 (*)(s32, s32 *, s32 *, s32 *))RotTransPers)(param_2, &sxy, &p, &flag); \ + if (flag < 0) { \ + *param_1 = sxy = 0; \ + } else { \ + *param_1 = sxy; \ + } \ + return param_1; \ + } + +#define DEFINE_func_80131A34() \ + extern void func_8012A828(s32 a0, void *a1); \ + s32 func_80131A34(s32 a0, s32 a1) \ + { \ + extern s32 func_80131CF4(s32); \ + void *p; \ + p = (void *)((int (*)(int, int))func_80131CF4)(*(s32 *)(a0 + 0xBC), a1); \ + if (p != 0) { \ + if (a1 == 0xB || a1 == 8 || a1 == 0x20) { \ + *(s32 *)(a0 + 0xC4) |= 4; \ + } else { \ + *(s32 *)(a0 + 0xC4) &= -5; \ + } \ + func_8012A828(a0, p); \ + return 1; \ + } \ + return 0; \ + } + +#define DEFINE_func_801778A8() \ + void func_801778A8(int param_1, unsigned int param_2, short param_3, short param_4) { \ + register unsigned int uVar1 __asm__("$2"); \ + register unsigned int nib __asm__("$3"); \ + int iVar2; \ + register int im1 __asm__("$11"); \ + int p4; \ + register char *p __asm__("$7"); \ + short iVar4; \ + unsigned short uVar5; \ + register unsigned int mask __asm__("$12"); \ + uVar5 = 0x100; \ + iVar2 = (int)param_3; \ + iVar4 = 0; \ + if (0 < iVar2) { \ + im1 = iVar2 - 1; \ + p4 = (int)param_4; \ + mask = ~0x100; \ + p = (char *)(param_1 + 0xc); \ + do { \ + uVar1 = (param_2 << 16) >> 28; \ + nib = uVar1; \ + if (((uVar1 != 0) || ((int)iVar4 == im1)) || \ + ((int)iVar4 == p4)) { \ + uVar5 = 0; \ + } \ + param_2 = param_2 << 4; \ + *p = (char)(nib * 8 + 8); \ + *(unsigned short *)(p - 2) = uVar5 | (*(unsigned short *)(p - 2) & mask); \ + iVar4 = iVar4 + 1; \ + p = p + 0x14; \ + } while ((int)iVar4 < iVar2); \ + } \ + return; \ + } + +#define DEFINE_func_80161374() \ + extern void func_801599A4(void*); \ + extern void func_8015BDD0(s32*); \ + extern void func_8015BF48(s32*); \ + extern void func_80015954(s32, s32); \ + int func_80161374(int param_1, unsigned int param_2) { \ + extern int D_801152BC; \ + if ((param_2 == 0) || (param_2 == 0x8000)) { \ + ((void (*)(int))func_801599A4)(param_1); \ + ((void (*)(int))func_8015BDD0)(param_1); \ + return 1; \ + } \ + if ((param_2 & 0x4000) != 0) { \ + if ((D_801152BC != 0) || \ + (*(short *)(param_1 + 10) >= *(short *)(param_1 + 0x8a))) { \ + ((void (*)(int))func_801599A4)(param_1); \ + ((void (*)(int))func_8015BF48)(param_1); \ + return 1; \ + } \ + ((int (*)(int, int))func_80015954)(param_1 + 0x88, param_1 + 4); \ + return 0; \ + } \ + return 0; \ + } + +#define DEFINE_func_8014C4AC() \ + s32 aF8014C4AC(a0, a1, a2, a3, a4) \ + s32 a0; \ + s32 a1; \ + s32 a2; \ + s16 *a3; \ + u16 a4; \ + { \ + extern s32 D_80126CD0; \ + extern u16 D_8012693A; \ + extern u16 D_801152B8; \ + u16 t; \ + if (a0 == 0) { \ + return 0; \ + } \ + if (*(u16 *)a0 == 0) { \ + return 0; \ + } \ + if (a1 == 9 || a1 == 0x11 || a1 == 0x29 || a1 == 0xA || D_80126CD0 != a0) { \ + t = *(u16 *)(a0 + 0x5C); \ + *(u16 *)(a0 + 0x5E) = a1; \ + *(u16 *)(a0 + 0x62) = a4; \ + *(u16 *)(a0 + 0x60) = a2; \ + *(u16 *)(a0 + 0x5C) = t | 1; \ + *(V4U_8014C4AC *)(a0 + 0x7C) = *(V4U_8014C4AC *)a3; \ + *(u8 *)(a0 + 0xC9) = D_8012693A; \ + *(u8 *)(a0 + 0xC8) = D_801152B8; \ + return a0; \ + } \ + return 0; \ + } + +#define DEFINE_func_801376E8() \ + void *aF801376E8(int a0, int a1) \ + { \ + extern s32 D_801269F0; \ + extern u8 D_801269FD; \ + extern u16 D_80126A14[]; \ + extern s16 D_80126A1C; \ + extern s16 D_80126A20; \ + extern s16 D_80126A22; \ + extern s16 D_80126A24; \ + extern u16 D_80126A26; \ + u16 *p = (u16 *)a1; \ + s32 obj = (s32)&D_801269F0; \ + func_801377B4(a0, 0x6200, obj); \ + D_80126A1C = 0x1C; \ + D_801269FD = 0; \ + if (p != 0) { \ + D_80126A14[0] = p[0]; \ + D_80126A14[1] = p[1]; \ + } \ + func_80139BE0(obj); \ + D_80126A20 = (D_80126A14[0] + 0x28) - ((D_80126A24 + 0x28) >> 1); \ + D_80126A22 = D_80126A14[1] - ((s16)D_80126A26 >> 1); \ + return (void *)obj; \ + } + +#define DEFINE_func_80175820() \ + s32 func_80175820(void) \ + { \ + extern s16 D_800B9A02; \ + extern S_AE7BC_80175820_80175820 D_800AE7BC[]; \ + extern S_AF634_80175820_80175820 D_800AF634[]; \ + extern u8 D_8011F7A8; \ + u8 *p = (u8 *)&D_8011F7A8; \ + u16 *q; \ + u32 *ptr; \ + u32 old; \ + u32 *p2; \ + q = (u16 *)&(*(u16 *)&D_800B9A02); \ + ptr = D_800AE7BC[*q].f0; \ + old = ptr[2]; \ + ptr[2] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x20) & 0xffffff); \ + __asm__("" ::: "memory"); \ + p2 = *(u32 **)(p + *q * 4 + 0x18); \ + *p2 = (*p2 & 0xff000000) | (old & 0xffffff); \ + __asm__("" ::: "memory"); \ + { \ + s32 acc = D_800AF634[*q].g0; \ + s32 t = *(s32 *)(p + *q * 4 + 0x18) - 0x14; \ + D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x20) - t) >> 2); \ + } \ + } + +#define DEFINE_func_801759D8() \ + s32 func_801759D8(void) \ + { \ + extern u8 D_8011F7B1; \ + extern s16 D_800B9A02; \ + extern S_AE7BC_801759D8 D_800AE7BC[]; \ + extern S_AF634_801759D8 D_800AF634[]; \ + extern u8 D_8011F7A8; \ + u8 *p = (u8 *)&D_8011F7A8; \ + u16 *q; \ + u32 *ptr; \ + u32 old; \ + u32 *p2; \ + if (D_8011F7B1 != 0) { \ + return; \ + } \ + q = (u16 *)&(*(u16 *)&D_800B9A02); \ + ptr = D_800AE7BC[*q].f0; \ + old = ptr[1]; \ + ptr[1] = (old & 0xff000000) | (*(u32 *)(p + *q * 4 + 0x40) & 0xffffff); \ + __asm__("" ::: "memory"); \ + p2 = *(u32 **)(p + *q * 4 + 0x38); \ + *p2 = (*p2 & 0xff000000) | (old & 0xffffff); \ + __asm__("" ::: "memory"); \ + { \ + s32 acc = D_800AF634[*q].g0; \ + s32 t = *(s32 *)(p + *q * 4 + 0x38) - 0x14; \ + D_800AF634[*q].g0 = acc + ((*(s32 *)(p + *q * 4 + 0x40) - t) >> 2); \ + } \ + } + +#define DEFINE_func_8012B77C() \ + extern s32 ratan2(s32 a0, s32 a1); \ + extern s32 func_80047948(s32 a0); /* rsin-like: angle (0..0xFFF) -> 1.12 fixed */ \ + extern s32 func_8004787C(s32 a0); /* rcos-like: angle (0..0xFFF) -> 1.12 fixed */ \ + s32 func_8012B77C(s32 out, s32 from, s32 to) { \ + Ang2_8012B77C_8012B77C t; \ + s32 dx, dy, dz; \ + s32 ang; \ + s32 r1, r2; \ + dz = *(s16 *)(to + 0xA) - *(s16 *)(from + 0xA); \ + dx = *(s16 *)(to + 0x2) - *(s16 *)(from + 0x2); \ + dy = *(s16 *)(to + 0x6) - *(s16 *)(from + 0x6); \ + ang = (ratan2(-dz, dx) - 0x400) & 0xFFF; \ + t.hi = ang; \ + r1 = func_80047948(ang); \ + r2 = func_8004787C(ang); \ + dz = (dz * r1 + dx * r2) >> 12; \ + t.lo = ratan2(dy, -dz); \ + *(Ang2_8012B77C_8012B77C *)out = t; \ + return out; \ + } + +#define DEFINE_func_8014E5B4() \ + s32 aF8014E5B4(s32 a0, void *a1, void *a2) \ + { \ + extern u8 D_801202A0[]; \ + register u8 *p __asm__("$17"); \ + register u8 *q __asm__("$16"); \ + u8 *e; \ + s32 t; \ + p = D_801202A0; \ + if (p < p + 0x6480) { \ + e = p + 0x6480; \ + q = p + 0xE; \ + loop: \ + if (*(u16 *)p != 0) { \ + if ((*(u16 *)(q + 0x4E) & 0x40) != 0) { \ + t = *(s32 *)(q + 0x4A); \ + if (t != 0) { \ + if (func_80135888(*(s32 *)(q + 0x12), t, (s32)a1, (s32)a2) != 0) { \ + *(u8 **)(a0 + 0x17C) = p; \ + *(u16 *)(a0 + 6) = *(u16 *)(q - 8); \ + *(u16 *)(a0 + 0xE) = *(u16 *)q; \ + return 1; \ + } \ + } \ + } \ + } \ + p += 0x10C; \ + q += 0x10C; \ + if (p < e) { \ + goto loop; \ + } \ + } \ + return 0; \ + } + +#define DEFINE_func_80173A60() \ + extern s32 func_8014C118(void*, s32, s32); \ + extern void func_80174684(void *); \ + extern void func_80173B4C(void*); \ + void func_80173A60(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5) { \ + extern s32 D_80126B58; \ + extern s32 D_80127508; \ + extern s16 D_80126B30; \ + extern struct S80126B38 D_80126B38; \ + extern s16 D_80126B3A; \ + extern s16 D_80126B3C; \ + extern s16 D_8011F9C8; \ + extern s16 D_80126938; \ + extern s32 D_8012750C; \ + s32 *s1 = &D_80126B58; \ + s32 v0; \ + if (a2 != 0) { \ + D_80127508 = ((s32 (*)(s32, s32, s32))func_8014C118)((s32)s1, a2, (s16)a3); \ + } else { \ + D_80127508 = 0; \ + } \ + v0 = s1[8]; \ + __builtin_memcpy(&D_80126B30, arg5, 8); \ + (*(s16 *)&D_80126B38) = a0; \ + D_80126B3A = a1; \ + D_80126B3C = *(u16 *)(v0 + 0x12); \ + func_80174684((void *)func_80173B4C); \ + D_8011F9C8 = 0; \ + D_80126938 = 0; \ + D_8012750C = 0; \ + } + +#define DEFINE_func_80138DE0() \ + extern s32 func_80138ED0(u8 *param_1, u32 param_2, u8 *param_3); \ + s32 func_80138DE0(u8 *arg0, u8 arg1, s32 arg2) { \ + extern s32 D_80127548[]; \ + extern u8 D_800D3AB4[]; \ + u16 *p; \ + if (D_80127548[0] == 0) { \ + return 0; \ + } \ + p = (u16 *)(arg0 + 0x44); \ + if ((*(u32 *)(arg0 + 8) & 0x400) == 0) { \ + p = (u16 *)(arg0 + 0x10); \ + if (*(s16 *)(arg0 + 4) == 8) { \ + p = (u16 *)(arg0 + 0x44); \ + } \ + } \ + if (arg1 >= 0xE0) { \ + arg2 = func_80138ED0(arg0, 0x1F, D_800D3AB4); \ + if (arg2 != 0) { \ + return 0; \ + } \ + *p = *p + 2; \ + } else if (arg1 >= 0x20) { \ + arg2 = func_80138ED0(arg0, (u16)(arg1 - 0x20), D_800D3AB4); \ + if (arg2 != 0) { \ + return 0; \ + } \ + *p = *p + 1; \ + } \ + if (arg2 != 0) { \ + return 0; \ + } \ + D_80127548[0] = D_80127548[0] - 1; \ + return D_80127548[0]; \ + } + +#define DEFINE_func_8014A738() \ + extern s32 func_80029178(s32); \ + s32 func_8014A738(void *arg0) { \ + extern u8 D_801202A0[]; \ + Vec_8014A738 d; \ + u32 i; \ + Ent_801202A0 *base; \ + if ((func_80029178(0x83) & 0xFF) == 0) { \ + return 0; \ + } \ + base = (Ent_801202A0 *)D_801202A0; \ + for (i = 0; i < 0x60; i++) { \ + if (base[i].state == 7) { \ + d.vx = ((Ent_801202A0 *)arg0)->x - base[i].x; \ + d.vz = ((Ent_801202A0 *)arg0)->z - base[i].z; \ + if (d.vx >= 0) { \ + if (d.vx < 0x40) { \ + goto zcheck; \ + } \ + } else { \ + if (-d.vx < 0x40) { \ + goto zcheck; \ + } \ + } \ + continue; \ + zcheck: \ + if (d.vz >= 0) { \ + if (d.vz < 0x40) { \ + goto found; \ + } \ + } else { \ + if (-d.vz < 0x40) { \ + goto found; \ + } \ + } \ + continue; \ + found: \ + return 1; \ + } \ + } \ + return 0; \ + } + +#define DEFINE_func_80133298() \ + extern void func_8012F0BC(s32 *a0, s32 *a1, s32 *a2); \ + extern void func_8012B2CC(s32 a0); \ + extern void func_8013339C(s16 *a0, s16 *a1); \ + extern void func_8012F1A4(s32 *a0, s32 a1, s32 *a2); \ + void func_80133298(s32 *a0) \ + { \ + extern u8 D_80126B5C; /* canonical decl (engine_core.h DEFINE_func_8012BD14) */ \ + extern s32 D_80126B5C_w __asm__("D_80126B5C"); /* same symbol, s32 view */ \ + extern s32 D_80126B60; \ + extern s32 D_80126B64; \ + s32 in[3]; \ + s32 out[3]; \ + s32 tmp[3]; \ + Blk32L_80133298 m; \ + in[0] = D_80126B5C_w; \ + in[1] = D_80126B60; \ + in[2] = D_80126B64; \ + func_8012F0BC((s32 *)(a0[8] + 0x34), in, tmp); \ + func_8012B2CC((s32)a0); \ + m = *(Blk32L_80133298 *)(a0[8] + 0x34); \ + func_8013339C((s16 *)&m, (s16 *)(a0[8] + 0x18)); \ + func_8012F1A4((s32 *)&m, (s32)tmp, out); \ + D_80126B5C_w = out[0]; \ + D_80126B60 = out[1]; \ + D_80126B64 = out[2]; \ + } + +#define DEFINE_func_8014D610() \ + extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); \ + extern s32 func_8014C918(s32 a0, s32 a1); \ + s32 func_8014D610(s32 param_1, s32 param_2, u16 *param_3) { \ + extern u8 D_801202A0[]; \ + u16 *psVar4; \ + u8 *puVar3; \ + s32 iVar2; \ + psVar4 = (u16 *)D_801202A0; \ + while (psVar4 < (u16 *)(D_801202A0 + 0x6480)) { \ + puVar3 = (u8 *)psVar4 + 0x75; \ + if (*psVar4 != 0 && (*(u16 *)(puVar3 - 0x19) & 0x400) != 0 && \ + *(s32 *)(puVar3 - 0x1D) != 0 && \ + *(s16 *)(puVar3 - 0x6B) >= *(s16 *)(param_1 + 0xA)) { \ + iVar2 = ((s32 (*)(s32, s32, s32, u16 *))func_80135A4C)( \ + *(s32 *)(puVar3 - 0x55), *(s32 *)(puVar3 - 0x1D), param_2, param_3); \ + if (iVar2 != 0) { \ + *(s32 *)(param_1 + 0x174) = (s32)psVar4; \ + puVar3[-1] = 1; \ + *(u16 *)(param_1 + 6) = param_3[0]; \ + *(u16 *)(param_1 + 0xA) = param_3[1]; \ + *(u16 *)(param_1 + 0xE) = param_3[2]; \ + *(u16 *)(param_1 + 0x16E) = func_8014C918(param_1, *puVar3) & 0xff; \ + return 1; \ + } \ + } \ + psVar4 += 0x86; \ + } \ + return 0; \ + } + +#define DEFINE_func_80163534() \ + extern void func_80163664(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32); \ + void func_80163534(a0, a1, a2, a3, a4, a5) \ + s32 a0; \ + u16 a1; \ + u16 a2; \ + s32 a3; \ + u16 a4; \ + u16 *a5; \ + { \ + extern s32 D_80115100; \ + extern s32 D_80115200; \ + extern s32 D_80115204; \ + extern s32 D_80115208; \ + extern u16 D_80126B18[]; \ + extern u16 D_801270B0[]; \ + extern u16 D_801270B2; \ + extern u16 D_801270B4; \ + extern u16 D_80126B1A[]; \ + extern u16 D_80126B1C; \ + extern s32 D_80114EB0; \ + extern s32 D_80114EC8; \ + extern s32 D_8011DAF0; \ + extern s32 D_80115298; \ + extern s32 D_80126734; \ + s32 *p = &D_80115200; \ + *p = 0; \ + D_80115204 = 0; \ + D_80115208 = 0; \ + D_801270B0[0] = *(u16 *)(a0 + 0x44) + a5[0]; \ + D_801270B2 = *(u16 *)(a0 + 0x46) + a5[1]; \ + D_801270B4 = *(u16 *)(a0 + 0x48) + a5[2]; \ + D_80126B18[0] = *(u16 *)(a0 + 0x6) + a5[0]; \ + D_80126B1A[0] = *(u16 *)(a0 + 0xA) + a5[1]; \ + D_80126B1C = *(u16 *)(a0 + 0xE) + a5[2]; \ + *p = ((s32 (*)(s32, u16, u16, s32, s32, s32, s32, s32, s32, s32, u16, s32, s32))func_80163664)(a0, a1, a2, (s32)D_801270B0, (s32)D_80126B18, \ + (s32)&D_80114EB0, (s32)&D_80114EC8, (s32)&D_80115100, \ + (s32)&D_8011DAF0, a3, a4, (s32)&D_80115298, \ + (s32)&D_80126734); \ + } + +#define DEFINE_func_8012A1BC() \ + void func_8012A1BC(void) { \ + extern s16 D_80120218; \ + extern s16 D_80120222; \ + extern s16 D_80120224; \ + extern s16 D_80120226; \ + extern s16 D_80120228; \ + extern s16 D_8012022A; \ + extern s16 D_8012029A; \ + extern s32 D_80120200, D_80120204, D_80120208, D_8012020C; \ + extern s16 D_80120210; \ + extern s16 D_80120220; \ + extern s32 D_80120294; \ + extern s16 D_80120298; \ + extern s32 D_80126950, D_80126954, D_80126958, D_8012695C; \ + extern Blk8 D_80126960, D_80126968; \ + extern u16 D_80126970, D_80126972, D_80126974, D_80126976, D_80126978, D_8012697A; \ + extern s32 D_801269E4; \ + extern u16 D_801269E8, D_801269EA; \ + register s32 r2 __asm__("$2"), r3 __asm__("$3"), r4 __asm__("$4"), r5 __asm__("$5"); \ + register u16 r6 __asm__("$6"), r7 __asm__("$7"); \ + register s32 r8 __asm__("$8"); \ + register u16 r9 __asm__("$9"), r10 __asm__("$10"); \ + r2 = D_80120200; r3 = D_80120204; r4 = D_80120208; r5 = D_8012020C; \ + r6 = (*(u16 *)&D_80120228); r7 = (*(u16 *)&D_8012022A); r8 = D_80120294; r9 = (*(u16 *)&D_80120298); r10 = (*(u16 *)&D_8012029A); \ + D_80126950 = r2; D_80126954 = r3; D_80126958 = r4; D_8012695C = r5; \ + __asm__ __volatile__("" ::: "memory"); \ + D_80126960 = (*(Blk8 *)&D_80120210); \ + r2 = (*(u16 *)&D_80120220); r3 = (*(u16 *)&D_80120222); r4 = (*(u16 *)&D_80120224); r5 = (*(u16 *)&D_80120226); \ + D_80126968 = (*(Blk8 *)&D_80120218); \ + D_80126978 = r6; D_8012697A = r7; D_801269E4 = r8; D_801269E8 = r9; D_801269EA = r10; \ + D_80126970 = r2; D_80126972 = r3; D_80126974 = r4; D_80126976 = r5; \ + } + +#define DEFINE_func_801749C8() \ + extern u16 D_80126B5E; \ + extern u16 D_80126B62; \ + extern u16 D_80126B66; \ + extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); \ + extern s32 func_80012ABC(s32, s32, s32); \ + extern void func_80049CAC(s32 a0, s32 a1); \ + extern void func_8012F14C(s32 a0, s32 a1, s32 a2); \ + s32 func_801749C8(s32 param_1) \ + { \ + Buf_c1 buf; \ + register s32 iVar5 __asm__("$18"); \ + register u32 iVar4 __asm__("$17"); \ + *(s32 *)(param_1 + 8) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 8), (s32)*(s16 *)(param_1 + 0xc), 4); \ + *(s32 *)(param_1 + 0x10) = (s16)((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x10), (s32)*(s16 *)(param_1 + 0x14), 4); \ + *(s16 *)(param_1 + 0x18) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x18), (s32)*(s16 *)(param_1 + 0x20), 4); \ + *(s16 *)(param_1 + 0x1a) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1a), (s32)*(s16 *)(param_1 + 0x22), 4); \ + *(s16 *)(param_1 + 0x1c) = ((s16 (*)(s32, s32, s32))func_80012ABC)((s32)*(s16 *)(param_1 + 0x1c), (s32)*(s16 *)(param_1 + 0x24), 4); \ + *(s16 *)(param_1 + 0x28) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x28), (s32)*(s16 *)(param_1 + 0x2e), 0x10); \ + *(s16 *)(param_1 + 0x2a) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2a), (s32)*(s16 *)(param_1 + 0x30), 0x10); \ + *(s16 *)(param_1 + 0x2c) = ((s16 (*)(s32, s32, s32))func_80012C6C)((s32)*(s16 *)(param_1 + 0x2c), (s32)*(s16 *)(param_1 + 0x32), 0x10); \ + iVar4 = (u16)D_80126B66; \ + *(s32 *)(param_1 + 0x48) = *(s16 *)(param_1 + 0x28) + (iVar5 = (s16)D_80126B5E); \ + *(s32 *)(param_1 + 0x4c) = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; \ + *(s32 *)(param_1 + 0x50) = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; \ + func_80049CAC(param_1 + 0x18, (s32)&buf); \ + buf.f14 = *(s16 *)(param_1 + 0x28) + iVar5; \ + buf.f18 = *(s16 *)(param_1 + 0x2a) + (s16)D_80126B62; \ + buf.f1c = *(s16 *)(param_1 + 0x2c) + (s16)iVar4; \ + buf.f20 = 0; \ + buf.f22 = 0; \ + buf.f24 = (s16)*(s32 *)(param_1 + 0x10); \ + ((void (*)(s32, s32, s32))func_8012F14C)((s32)&buf, (s32)&buf.f20, (s32)&buf.f28); \ + *(s32 *)(param_1 + 0x3c) = buf.f28; \ + *(s32 *)(param_1 + 0x40) = buf.f2a; \ + *(s32 *)(param_1 + 0x44) = buf.f2c; \ + } + #endif