From 9d9cd580280324d81c0fd5a4b2c992689503cf4a Mon Sep 17 00:00:00 2001 From: Drew T <50529377+Druthulu@users.noreply.github.com> Date: Sun, 26 Jul 2026 15:36:06 -0600 Subject: [PATCH] =?UTF-8?q?feat(phase-29):=20T0.4=20harvest=20=E2=80=94=20?= =?UTF-8?q?272=20return-axis=20members=20banked=20(+26,928=20ins)=20+=20th?= =?UTF-8?q?e=20=C2=A784=20recompute=20in=20family=5Fremap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit THE §85 WIDEN PAID OFF AS PREDICTED. It is a ONE-TIME fleet edit, so once committed the `conflicting types` blocker was gone for EVERY member of both families at once: - sample 8 first (probe-before-scale): 8/8 banked with PLAIN harvest_verify, no ladder needed - full sweep: 264 banked / 0 failed across 132 overlays; 10 skipped as not-stub - total 272 members ~= 27k ins, ZERO agent tokens R22 clean-fleet 140/140 BYTE-IDENTICAL; dedup 1886/0; 0 NON_MATCHING (G4). Fleet: instr 80.6 -> 80.8% (10,589,503 -> 10,616,431, +26,928) · fn-count 89.19 -> 89.26%. distinct-code UNCHANGED at 68.3% — propagation moves the DISPLAY metric, not the RE-completeness one (the SESSION-19 split, reconfirmed). §84 RECOMPUTE now implemented in tools/family_remap.py (fix_derived_offsets), wired into all three apply_remap call sites as a PRE-pass on the exemplar body (the literal is ambiguous as a substitution token, so it cannot be a table entry): correct_literal = mapped(aliased_sym) - mapped(base_sym) Verified by negative control: the hand-solved case recomputes 0x20 -> 0x18 exactly, and a site whose target endpoint is NOT a mapped symbol is left byte-for-byte alone AND REPORTED in info ["derived_offsets"] (R32 — a silent skip is a defect, and a silent skip is how this bug survived). --- docs/progress.fleet.md | 282 +++++++++++----------- src/ov_SC01_001/ov_SC01_001_after.c | 40 ++- src/ov_SC01_001/ov_SC01_001_jr_8012ACE0.c | 49 +++- src/ov_SC01_004/ov_SC01_004_after.c | 40 ++- src/ov_SC01_004/ov_SC01_004_jr_8012ACE0.c | 49 +++- src/ov_SC01_005/ov_SC01_005_after.c | 40 ++- src/ov_SC01_005/ov_SC01_005_jr_8012ACE0.c | 49 +++- src/ov_SC01_006/ov_SC01_006_after.c | 40 ++- src/ov_SC01_006/ov_SC01_006_jr_8012ACE0.c | 49 +++- src/ov_SC01_008/ov_SC01_008_after.c | 40 ++- src/ov_SC01_008/ov_SC01_008_jr_8012ACE0.c | 49 +++- src/ov_SC01_009/ov_SC01_009_after.c | 40 ++- src/ov_SC01_009/ov_SC01_009_jr_8012ACE0.c | 49 +++- src/ov_SC01_074/ov_SC01_074_after.c | 40 ++- src/ov_SC01_074/ov_SC01_074_jr_8012ACE0.c | 49 +++- src/ov_SC01_077/ov_SC01_077_after.c | 40 ++- src/ov_SC01_077/ov_SC01_077_jr_8012ACE0.c | 49 +++- src/ov_SC01_080/ov_SC01_080_after.c | 40 ++- src/ov_SC01_080/ov_SC01_080_jr_8012ACE0.c | 49 +++- src/ov_SC01_084/ov_SC01_084_after.c | 40 ++- src/ov_SC01_084/ov_SC01_084_jr_8012ACE0.c | 49 +++- src/ov_SC02_000/ov_SC02_000_after.c | 40 ++- src/ov_SC02_000/ov_SC02_000_jr_8012ACE0.c | 49 +++- src/ov_SC02_003/ov_SC02_003_after.c | 40 ++- src/ov_SC02_003/ov_SC02_003_jr_8012ACE0.c | 49 +++- src/ov_SC02_004/ov_SC02_004_after.c | 40 ++- src/ov_SC02_004/ov_SC02_004_jr_8012ACE0.c | 49 +++- src/ov_SC02_005/ov_SC02_005_after.c | 40 ++- src/ov_SC02_005/ov_SC02_005_jr_8012ACE0.c | 49 +++- src/ov_SC02_011/ov_SC02_011_after.c | 40 ++- src/ov_SC02_011/ov_SC02_011_jr_8012ACE0.c | 49 +++- src/ov_SC02_015/ov_SC02_015_after.c | 40 ++- src/ov_SC02_015/ov_SC02_015_jr_8012ACE0.c | 49 +++- src/ov_SC02_016/ov_SC02_016_after.c | 40 ++- src/ov_SC02_016/ov_SC02_016_jr_8012ACE0.c | 49 +++- src/ov_SC02_017/ov_SC02_017_after.c | 40 ++- src/ov_SC02_017/ov_SC02_017_jr_8012ACE0.c | 49 +++- src/ov_SC02_021/ov_SC02_021_after.c | 40 ++- src/ov_SC02_021/ov_SC02_021_jr_8012ACE0.c | 49 +++- src/ov_SC02_026/ov_SC02_026_after.c | 40 ++- src/ov_SC02_026/ov_SC02_026_jr_8012ACE0.c | 49 +++- src/ov_SC02_027/ov_SC02_027_after.c | 40 ++- src/ov_SC02_027/ov_SC02_027_jr_8012ACE0.c | 49 +++- src/ov_SC02_028/ov_SC02_028_after.c | 40 ++- src/ov_SC02_028/ov_SC02_028_jr_8012ACE0.c | 49 +++- src/ov_SC02_031/ov_SC02_031_after.c | 40 ++- src/ov_SC02_031/ov_SC02_031_jr_8012ACE0.c | 49 +++- src/ov_SC02_035/ov_SC02_035_after.c | 40 ++- src/ov_SC02_035/ov_SC02_035_jr_8012ACE0.c | 49 +++- src/ov_SC02_039/ov_SC02_039_after.c | 40 ++- src/ov_SC02_039/ov_SC02_039_jr_8012ACE0.c | 49 +++- src/ov_SC02_041/ov_SC02_041_after.c | 40 ++- src/ov_SC02_041/ov_SC02_041_jr_8012ACE0.c | 49 +++- src/ov_SC03_001/ov_SC03_001_after.c | 40 ++- src/ov_SC03_001/ov_SC03_001_jr_8012ACE0.c | 49 +++- src/ov_SC03_002/ov_SC03_002_after.c | 40 ++- src/ov_SC03_002/ov_SC03_002_jr_8012ACE0.c | 49 +++- src/ov_SC03_003/ov_SC03_003_after.c | 40 ++- src/ov_SC03_003/ov_SC03_003_jr_8012ACE0.c | 49 +++- src/ov_SC03_006/ov_SC03_006_after.c | 40 ++- src/ov_SC03_006/ov_SC03_006_jr_8012ACE0.c | 49 +++- src/ov_SC03_007/ov_SC03_007_after.c | 40 ++- src/ov_SC03_007/ov_SC03_007_jr_8012ACE0.c | 49 +++- src/ov_SC03_010/ov_SC03_010_after.c | 40 ++- src/ov_SC03_010/ov_SC03_010_jr_8012ACE0.c | 49 +++- src/ov_SC03_011/ov_SC03_011_after.c | 40 ++- src/ov_SC03_011/ov_SC03_011_jr_8012ACE0.c | 49 +++- src/ov_SC03_012/ov_SC03_012_after.c | 40 ++- src/ov_SC03_012/ov_SC03_012_jr_8012ACE0.c | 49 +++- src/ov_SC03_013/ov_SC03_013_after.c | 40 ++- src/ov_SC03_013/ov_SC03_013_jr_8012ACE0.c | 49 +++- src/ov_SC03_014/ov_SC03_014_after.c | 40 ++- src/ov_SC03_014/ov_SC03_014_jr_8012ACE0.c | 49 +++- src/ov_SC03_015/ov_SC03_015_after.c | 40 ++- src/ov_SC03_015/ov_SC03_015_jr_8012ACE0.c | 49 +++- src/ov_SC03_023/ov_SC03_023_after.c | 40 ++- src/ov_SC03_023/ov_SC03_023_jr_8012ACE0.c | 49 +++- src/ov_SC03_024/ov_SC03_024_after.c | 40 ++- src/ov_SC03_024/ov_SC03_024_jr_8012ACE0.c | 49 +++- src/ov_SC03_028/ov_SC03_028_after.c | 40 ++- src/ov_SC03_028/ov_SC03_028_jr_8012ACE0.c | 49 +++- src/ov_SC03_029/ov_SC03_029_after.c | 40 ++- src/ov_SC03_029/ov_SC03_029_jr_8012ACE0.c | 49 +++- src/ov_SC03_030/ov_SC03_030_after.c | 40 ++- src/ov_SC03_030/ov_SC03_030_jr_8012ACE0.c | 49 +++- src/ov_SC03_031/ov_SC03_031_after.c | 40 ++- src/ov_SC03_031/ov_SC03_031_jr_8012ACE0.c | 49 +++- src/ov_SC03_089/ov_SC03_089_after.c | 40 ++- src/ov_SC03_089/ov_SC03_089_jr_8012ACE0.c | 49 +++- src/ov_SC03_090/ov_SC03_090_after.c | 40 ++- src/ov_SC03_090/ov_SC03_090_jr_8012ACE0.c | 49 +++- src/ov_SC03_091/ov_SC03_091_after.c | 40 ++- src/ov_SC03_091/ov_SC03_091_jr_8012ACE0.c | 49 +++- src/ov_SC03_092/ov_SC03_092_after.c | 40 ++- src/ov_SC03_092/ov_SC03_092_jr_8012ACE0.c | 49 +++- src/ov_SC03_093/ov_SC03_093_after.c | 40 ++- src/ov_SC03_093/ov_SC03_093_jr_8012ACE0.c | 49 +++- src/ov_SC03_094/ov_SC03_094_after.c | 40 ++- src/ov_SC03_094/ov_SC03_094_jr_8012ACE0.c | 49 +++- src/ov_SC03_095/ov_SC03_095_after.c | 40 ++- src/ov_SC03_095/ov_SC03_095_jr_8012ACE0.c | 49 +++- src/ov_SC03_096/ov_SC03_096_after.c | 40 ++- src/ov_SC03_096/ov_SC03_096_jr_8012ACE0.c | 49 +++- src/ov_SC03_097/ov_SC03_097_after.c | 40 ++- src/ov_SC03_097/ov_SC03_097_jr_8012ACE0.c | 49 +++- src/ov_SC03_098/ov_SC03_098_after.c | 40 ++- src/ov_SC03_098/ov_SC03_098_jr_8012ACE0.c | 49 +++- src/ov_SC03_099/ov_SC03_099_after.c | 40 ++- src/ov_SC03_099/ov_SC03_099_jr_8012ACE0.c | 49 +++- src/ov_SC03_100/ov_SC03_100_after.c | 40 ++- src/ov_SC03_100/ov_SC03_100_jr_8012ACE0.c | 49 +++- src/ov_SC03_101/ov_SC03_101_after.c | 40 ++- src/ov_SC03_101/ov_SC03_101_jr_8012ACE0.c | 49 +++- src/ov_SC03_102/ov_SC03_102_after.c | 40 ++- src/ov_SC03_102/ov_SC03_102_jr_8012ACE0.c | 49 +++- src/ov_SC03_103/ov_SC03_103_after.c | 40 ++- src/ov_SC03_103/ov_SC03_103_jr_8012ACE0.c | 49 +++- src/ov_SC03_104/ov_SC03_104_after.c | 40 ++- src/ov_SC03_104/ov_SC03_104_jr_8012ACE0.c | 49 +++- src/ov_SC03_105/ov_SC03_105_after.c | 40 ++- src/ov_SC03_105/ov_SC03_105_jr_8012ACE0.c | 49 +++- src/ov_SC03_108/ov_SC03_108_after.c | 40 ++- src/ov_SC03_108/ov_SC03_108_jr_8012ACE0.c | 49 +++- src/ov_SC03_109/ov_SC03_109_after.c | 40 ++- src/ov_SC03_109/ov_SC03_109_jr_8012ACE0.c | 49 +++- src/ov_SC03_110/ov_SC03_110_after.c | 40 ++- src/ov_SC03_110/ov_SC03_110_jr_8012ACE0.c | 49 +++- src/ov_SC03_111/ov_SC03_111_after.c | 40 ++- src/ov_SC03_111/ov_SC03_111_jr_8012ACE0.c | 49 +++- src/ov_SC03_112/ov_SC03_112_after.c | 40 ++- src/ov_SC03_112/ov_SC03_112_jr_8012ACE0.c | 49 +++- src/ov_SC03_113/ov_SC03_113_after.c | 40 ++- src/ov_SC03_113/ov_SC03_113_jr_8012ACE0.c | 49 +++- src/ov_SC03_114/ov_SC03_114_after.c | 40 ++- src/ov_SC03_114/ov_SC03_114_jr_8012ACE0.c | 49 +++- src/ov_SC03_115/ov_SC03_115_after.c | 40 ++- src/ov_SC03_115/ov_SC03_115_jr_8012ACE0.c | 49 +++- src/ov_SC03_116/ov_SC03_116_after.c | 40 ++- src/ov_SC03_116/ov_SC03_116_jr_8012ACE0.c | 49 +++- src/ov_SC03_117/ov_SC03_117_after.c | 40 ++- src/ov_SC03_117/ov_SC03_117_jr_8012ACE0.c | 49 +++- src/ov_SC03_118/ov_SC03_118_after.c | 40 ++- src/ov_SC03_118/ov_SC03_118_jr_8012ACE0.c | 49 +++- src/ov_SC03_119/ov_SC03_119_after.c | 40 ++- src/ov_SC03_119/ov_SC03_119_jr_8012ACE0.c | 49 +++- src/ov_SC03_121/ov_SC03_121_after.c | 40 ++- src/ov_SC03_121/ov_SC03_121_jr_8012ACE0.c | 49 +++- src/ov_SC03_124/ov_SC03_124_after.c | 40 ++- src/ov_SC03_124/ov_SC03_124_jr_8012ACE0.c | 49 +++- src/ov_SC03_125/ov_SC03_125_after.c | 40 ++- src/ov_SC03_125/ov_SC03_125_jr_8012ACE0.c | 49 +++- src/ov_SC03_126/ov_SC03_126_after.c | 40 ++- src/ov_SC03_126/ov_SC03_126_jr_8012ACE0.c | 49 +++- src/ov_SC04_000/ov_SC04_000_after.c | 40 ++- src/ov_SC04_000/ov_SC04_000_jr_8012ACE0.c | 49 +++- src/ov_SC04_002/ov_SC04_002_after.c | 40 ++- src/ov_SC04_002/ov_SC04_002_jr_8012ACE0.c | 49 +++- src/ov_SC04_003/ov_SC04_003_after.c | 40 ++- src/ov_SC04_003/ov_SC04_003_jr_8012ACE0.c | 49 +++- src/ov_SC04_004/ov_SC04_004_after.c | 40 ++- src/ov_SC04_004/ov_SC04_004_jr_8012ACE0.c | 49 +++- src/ov_SC04_005/ov_SC04_005_after.c | 40 ++- src/ov_SC04_005/ov_SC04_005_jr_8012ACE0.c | 49 +++- src/ov_SC04_006/ov_SC04_006_after.c | 40 ++- src/ov_SC04_006/ov_SC04_006_jr_8012ACE0.c | 49 +++- src/ov_SC04_007/ov_SC04_007_after.c | 40 ++- src/ov_SC04_007/ov_SC04_007_jr_8012ACE0.c | 49 +++- src/ov_SC04_008/ov_SC04_008_after.c | 40 ++- src/ov_SC04_008/ov_SC04_008_jr_8012ACE0.c | 49 +++- src/ov_SC04_009/ov_SC04_009_after.c | 40 ++- src/ov_SC04_009/ov_SC04_009_jr_8012ACE0.c | 49 +++- src/ov_SC04_010/ov_SC04_010_after.c | 40 ++- src/ov_SC04_010/ov_SC04_010_jr_8012ACE0.c | 49 +++- src/ov_SC04_011/ov_SC04_011_after.c | 40 ++- src/ov_SC04_011/ov_SC04_011_jr_8012ACE0.c | 49 +++- src/ov_SC04_012/ov_SC04_012_after.c | 40 ++- src/ov_SC04_012/ov_SC04_012_jr_8012ACE0.c | 49 +++- src/ov_SC04_015/ov_SC04_015_after.c | 40 ++- src/ov_SC04_015/ov_SC04_015_jr_8012ACE0.c | 49 +++- src/ov_SC04_016/ov_SC04_016_after.c | 40 ++- src/ov_SC04_016/ov_SC04_016_jr_8012ACE0.c | 49 +++- src/ov_SC04_018/ov_SC04_018_after.c | 40 ++- src/ov_SC04_018/ov_SC04_018_jr_8012ACE0.c | 49 +++- src/ov_SC04_019/ov_SC04_019_after.c | 40 ++- src/ov_SC04_019/ov_SC04_019_jr_8012ACE0.c | 49 +++- src/ov_SC04_020/ov_SC04_020_after.c | 40 ++- src/ov_SC04_020/ov_SC04_020_jr_8012ACE0.c | 49 +++- src/ov_SC04_021/ov_SC04_021_after.c | 40 ++- src/ov_SC04_021/ov_SC04_021_jr_8012ACE0.c | 49 +++- src/ov_SC05_000/ov_SC05_000_after.c | 40 ++- src/ov_SC05_000/ov_SC05_000_jr_8012ACE0.c | 49 +++- src/ov_SC05_001/ov_SC05_001_after.c | 40 ++- src/ov_SC05_001/ov_SC05_001_jr_8012ACE0.c | 49 +++- src/ov_SC05_002/ov_SC05_002_after.c | 40 ++- src/ov_SC05_002/ov_SC05_002_jr_8012ACE0.c | 49 +++- src/ov_SC05_003/ov_SC05_003_after.c | 40 ++- src/ov_SC05_003/ov_SC05_003_jr_8012ACE0.c | 49 +++- src/ov_SC05_004/ov_SC05_004_after.c | 40 ++- src/ov_SC05_004/ov_SC05_004_jr_8012ACE0.c | 49 +++- src/ov_SC05_005/ov_SC05_005_after.c | 40 ++- src/ov_SC05_005/ov_SC05_005_jr_8012ACE0.c | 49 +++- src/ov_SC05_006/ov_SC05_006_after.c | 40 ++- src/ov_SC05_006/ov_SC05_006_jr_8012ACE0.c | 49 +++- src/ov_SC05_007/ov_SC05_007_after.c | 40 ++- src/ov_SC05_007/ov_SC05_007_jr_8012ACE0.c | 49 +++- src/ov_SC05_008/ov_SC05_008_after.c | 40 ++- src/ov_SC05_008/ov_SC05_008_jr_8012ACE0.c | 49 +++- src/ov_SC05_009/ov_SC05_009_after.c | 40 ++- src/ov_SC05_009/ov_SC05_009_jr_8012ACE0.c | 49 +++- src/ov_SC05_010/ov_SC05_010_after.c | 40 ++- src/ov_SC05_010/ov_SC05_010_jr_8012ACE0.c | 49 +++- src/ov_SC05_011/ov_SC05_011_after.c | 40 ++- src/ov_SC05_011/ov_SC05_011_jr_8012ACE0.c | 49 +++- src/ov_SC05_017/ov_SC05_017_after.c | 40 ++- src/ov_SC05_017/ov_SC05_017_jr_8012ACE0.c | 49 +++- src/ov_SC05_018/ov_SC05_018_after.c | 40 ++- src/ov_SC05_018/ov_SC05_018_jr_8012ACE0.c | 49 +++- src/ov_SC05_019/ov_SC05_019_after.c | 40 ++- src/ov_SC05_019/ov_SC05_019_jr_8012ACE0.c | 49 +++- src/ov_SC06_000/ov_SC06_000_after.c | 40 ++- src/ov_SC06_000/ov_SC06_000_jr_8012ACE0.c | 49 +++- src/ov_SC06_006/ov_SC06_006_after.c | 40 ++- src/ov_SC06_006/ov_SC06_006_jr_8012ACE0.c | 49 +++- src/ov_SC06_008/ov_SC06_008_after.c | 40 ++- src/ov_SC06_008/ov_SC06_008_jr_8012ACE0.c | 49 +++- src/ov_SC06_010/ov_SC06_010_after.c | 40 ++- src/ov_SC06_010/ov_SC06_010_jr_8012ACE0.c | 49 +++- src/ov_SC06_011/ov_SC06_011_after.c | 40 ++- src/ov_SC06_011/ov_SC06_011_jr_8012ACE0.c | 49 +++- src/ov_SC06_013/ov_SC06_013_after.c | 40 ++- src/ov_SC06_013/ov_SC06_013_jr_8012ACE0.c | 49 +++- src/ov_SC06_014/ov_SC06_014_after.c | 40 ++- src/ov_SC06_014/ov_SC06_014_jr_8012ACE0.c | 49 +++- src/ov_SC06_015/ov_SC06_015_after.c | 40 ++- src/ov_SC06_015/ov_SC06_015_jr_8012ACE0.c | 49 +++- src/ov_SC06_016/ov_SC06_016_after.c | 40 ++- src/ov_SC06_016/ov_SC06_016_jr_8012ACE0.c | 49 +++- src/ov_SC06_018/ov_SC06_018_after.c | 40 ++- src/ov_SC06_018/ov_SC06_018_jr_8012ACE0.c | 49 +++- src/ov_SC06_020/ov_SC06_020_after.c | 40 ++- src/ov_SC06_020/ov_SC06_020_jr_8012ACE0.c | 49 +++- src/ov_SC06_022/ov_SC06_022_after.c | 40 ++- src/ov_SC06_022/ov_SC06_022_jr_8012ACE0.c | 49 +++- src/ov_SC06_024/ov_SC06_024_after.c | 40 ++- src/ov_SC06_024/ov_SC06_024_jr_8012ACE0.c | 49 +++- src/ov_SC06_025/ov_SC06_025_after.c | 40 ++- src/ov_SC06_025/ov_SC06_025_jr_8012ACE0.c | 49 +++- src/ov_SC06_027/ov_SC06_027_after.c | 40 ++- src/ov_SC06_027/ov_SC06_027_jr_8012ACE0.c | 49 +++- src/ov_SC06_029/ov_SC06_029_after.c | 40 ++- src/ov_SC06_029/ov_SC06_029_jr_8012ACE0.c | 49 +++- src/ov_SC06_030/ov_SC06_030_after.c | 40 ++- src/ov_SC06_030/ov_SC06_030_jr_8012ACE0.c | 49 +++- src/ov_SC06_032/ov_SC06_032_after.c | 40 ++- src/ov_SC06_032/ov_SC06_032_jr_8012ACE0.c | 49 +++- src/ov_SC06_033/ov_SC06_033_after.c | 40 ++- src/ov_SC06_033/ov_SC06_033_jr_8012ACE0.c | 49 +++- src/ov_SC07_000/ov_SC07_000_after.c | 40 ++- src/ov_SC07_000/ov_SC07_000_jr_8012ACE0.c | 49 +++- src/ov_SC07_001/ov_SC07_001_after.c | 40 ++- src/ov_SC07_001/ov_SC07_001_jr_8012ACE0.c | 49 +++- src/ov_SC07_002/ov_SC07_002_after.c | 40 ++- src/ov_SC07_002/ov_SC07_002_jr_8012ACE0.c | 49 +++- src/ov_SC07_007/ov_SC07_007.c | 49 +++- src/ov_SC07_007/ov_SC07_007_jr_80140608.c | 40 ++- src/ov_SC07_008/ov_SC07_008_after.c | 40 ++- src/ov_SC07_008/ov_SC07_008_jr_8012ACE0.c | 49 +++- src/ov_SC07_009/ov_SC07_009_after.c | 40 ++- src/ov_SC07_009/ov_SC07_009_jr_8012ACE0.c | 49 +++- src/ov_SC07_010/ov_SC07_010.c | 49 +++- src/ov_SC07_010/ov_SC07_010_jr_80140608.c | 40 ++- src/ov_SC07_011/ov_SC07_011.c | 49 +++- src/ov_SC07_011/ov_SC07_011_jr_80140608.c | 40 ++- tools/family_remap.py | 47 +++- 274 files changed, 12018 insertions(+), 415 deletions(-) diff --git a/docs/progress.fleet.md b/docs/progress.fleet.md index 83d0761c79..40314060df 100644 --- a/docs/progress.fleet.md +++ b/docs/progress.fleet.md @@ -4,16 +4,16 @@ # cross-binary collapsible-byte leverage: docs/duplicates.cross.md. # THREE progress metrics (all matter — see the labels): -FLEET fn-count byte-ident: 315470 / 353719 = 89.19% (REAL+LINKED+empties; FUNCTION-count, ×134-inflated — one crack counts per overlay) -FLEET instr-weighted : 10589503 / 13141652 = 80.6% (shipped .text across main + resident + 138 overlays; the decomp.dev-DISPLAY number) +FLEET fn-count byte-ident: 315742 / 353719 = 89.26% (REAL+LINKED+empties; FUNCTION-count, ×134-inflated — one crack counts per overlay) +FLEET instr-weighted : 10616431 / 13141652 = 80.8% (shipped .text across main + resident + 138 overlays; the decomp.dev-DISPLAY number) FLEET distinct-code(uniq): 3846656 / 5634875 = 68.3% (64912/87459 unique fns; the DISTINCT-RE number) MAIN game-code weighted : 436 / 60201 = 0.7% (INCLUDED in the fleet numbers above since 2026-07-22 — roadmap §1 metrics contract; LINKED-excluding Ghidra sig dated 2026-06-14; caveat is R34: no independent second oracle for a PS-X EXE, NOT drift) - (fleet EXCLUDING main, for continuity with pre-2026-07-22 readings: 10589067 / 13081451 = 80.9%) + (fleet EXCLUDING main, for continuity with pre-2026-07-22 readings: 10615995 / 13081451 = 81.2%) -FLEET REAL substantive : 313615 (of which dedup-shared 239530 via 1886 groups / 239604 instances) +FLEET REAL substantive : 313887 (of which dedup-shared 239530 via 1886 groups / 239604 instances) FLEET LINKED PsyQ objs : 959 FLEET NON_MATCHING : 7 (0 in any default build — G4) -FLEET INCLUDE_ASM stubs : 38242 +FLEET INCLUDE_ASM stubs : 37970 FLEET matchable : 353719 | binary | REAL | shared | LINKED | byte-ident | matchable | byte-ident % | @@ -21,140 +21,140 @@ FLEET matchable : 353719 | main | 54 | 2 | 959 | 1055 | 2096 | 50.3% | | resident | 129 | 0 | 0 | 131 | 145 | 90.3% | | ov_SC01_000 | 2253 | 1742 | 0 | 2253 | 2403 | 93.8% | -| ov_SC01_001 | 2253 | 1743 | 0 | 2255 | 2466 | 91.4% | -| ov_SC01_004 | 2242 | 1734 | 0 | 2243 | 2414 | 92.9% | -| ov_SC01_005 | 2272 | 1757 | 0 | 2272 | 2503 | 90.8% | -| ov_SC01_006 | 2272 | 1757 | 0 | 2272 | 2503 | 90.8% | -| ov_SC01_008 | 2242 | 1734 | 0 | 2244 | 2426 | 92.5% | -| ov_SC01_009 | 2268 | 1735 | 0 | 2269 | 2507 | 90.5% | -| ov_SC01_074 | 2246 | 1735 | 0 | 2248 | 2425 | 92.7% | -| ov_SC01_077 | 2428 | 1702 | 0 | 2430 | 2585 | 94.0% | -| ov_SC01_080 | 2284 | 1738 | 0 | 2284 | 2512 | 90.9% | -| ov_SC01_084 | 2291 | 1738 | 0 | 2296 | 2579 | 89.0% | -| ov_SC02_000 | 2344 | 1773 | 0 | 2344 | 2683 | 87.4% | -| ov_SC02_003 | 2344 | 1773 | 0 | 2344 | 2683 | 87.4% | -| ov_SC02_004 | 2250 | 1738 | 0 | 2250 | 2401 | 93.7% | -| ov_SC02_005 | 2358 | 1734 | 0 | 2368 | 2927 | 80.9% | -| ov_SC02_011 | 2370 | 1741 | 0 | 2381 | 2893 | 82.3% | -| ov_SC02_015 | 2251 | 1740 | 0 | 2251 | 2414 | 93.2% | -| ov_SC02_016 | 2285 | 1740 | 0 | 2288 | 2545 | 89.9% | -| ov_SC02_017 | 2328 | 1740 | 0 | 2336 | 2732 | 85.5% | -| ov_SC02_021 | 2257 | 1740 | 0 | 2257 | 2437 | 92.6% | -| ov_SC02_026 | 2273 | 1738 | 0 | 2279 | 2572 | 88.6% | -| ov_SC02_027 | 2296 | 1738 | 0 | 2305 | 2692 | 85.6% | -| ov_SC02_028 | 2298 | 1738 | 0 | 2308 | 2701 | 85.4% | -| ov_SC02_031 | 2284 | 1739 | 0 | 2289 | 2562 | 89.3% | -| ov_SC02_035 | 2259 | 1738 | 0 | 2262 | 2520 | 89.8% | -| ov_SC02_039 | 2243 | 1738 | 0 | 2243 | 2416 | 92.8% | -| ov_SC02_041 | 2281 | 1738 | 0 | 2284 | 2561 | 89.2% | -| ov_SC03_001 | 2379 | 1739 | 0 | 2396 | 2869 | 83.5% | -| ov_SC03_002 | 2305 | 1743 | 0 | 2320 | 2631 | 88.2% | -| ov_SC03_003 | 2253 | 1738 | 0 | 2254 | 2423 | 93.0% | -| ov_SC03_006 | 2319 | 1744 | 0 | 2328 | 2767 | 84.1% | -| ov_SC03_007 | 2298 | 1738 | 0 | 2302 | 2623 | 87.8% | -| ov_SC03_010 | 2261 | 1738 | 0 | 2261 | 2471 | 91.5% | -| ov_SC03_011 | 2267 | 1738 | 0 | 2273 | 2527 | 89.9% | -| ov_SC03_012 | 2245 | 1738 | 0 | 2246 | 2406 | 93.3% | -| ov_SC03_013 | 2266 | 1738 | 0 | 2266 | 2493 | 90.9% | -| ov_SC03_014 | 2324 | 1763 | 0 | 2324 | 2685 | 86.6% | -| ov_SC03_015 | 2324 | 1763 | 0 | 2324 | 2685 | 86.6% | -| ov_SC03_023 | 2252 | 1738 | 0 | 2253 | 2435 | 92.5% | -| ov_SC03_024 | 2312 | 1743 | 0 | 2319 | 2641 | 87.8% | -| ov_SC03_028 | 2292 | 1738 | 0 | 2296 | 2664 | 86.2% | -| ov_SC03_029 | 2293 | 1740 | 0 | 2303 | 2644 | 87.1% | -| ov_SC03_030 | 2266 | 1743 | 0 | 2268 | 2495 | 90.9% | -| ov_SC03_031 | 2263 | 1738 | 0 | 2266 | 2514 | 90.1% | -| ov_SC03_089 | 2280 | 1738 | 0 | 2287 | 2581 | 88.6% | -| ov_SC03_090 | 2281 | 1738 | 0 | 2289 | 2625 | 87.2% | -| ov_SC03_091 | 2284 | 1738 | 0 | 2292 | 2640 | 86.8% | -| ov_SC03_092 | 2294 | 1738 | 0 | 2306 | 2587 | 89.1% | -| ov_SC03_093 | 2270 | 1738 | 0 | 2274 | 2563 | 88.7% | -| ov_SC03_094 | 2265 | 1738 | 0 | 2271 | 2577 | 88.1% | -| ov_SC03_095 | 2255 | 1738 | 0 | 2258 | 2474 | 91.3% | -| ov_SC03_096 | 2255 | 1738 | 0 | 2258 | 2465 | 91.6% | -| ov_SC03_097 | 2285 | 1738 | 0 | 2292 | 2603 | 88.1% | -| ov_SC03_098 | 2263 | 1738 | 0 | 2266 | 2541 | 89.2% | -| ov_SC03_099 | 2256 | 1738 | 0 | 2259 | 2504 | 90.2% | -| ov_SC03_100 | 2266 | 1738 | 0 | 2270 | 2539 | 89.4% | -| ov_SC03_101 | 2266 | 1738 | 0 | 2270 | 2528 | 89.8% | -| ov_SC03_102 | 2259 | 1738 | 0 | 2262 | 2492 | 90.8% | -| ov_SC03_103 | 2261 | 1740 | 0 | 2264 | 2510 | 90.2% | -| ov_SC03_104 | 2288 | 1738 | 0 | 2295 | 2616 | 87.7% | -| ov_SC03_105 | 2280 | 1738 | 0 | 2287 | 2597 | 88.1% | -| ov_SC03_108 | 2247 | 1738 | 0 | 2247 | 2443 | 92.0% | -| ov_SC03_109 | 2250 | 1738 | 0 | 2252 | 2424 | 92.9% | -| ov_SC03_110 | 2254 | 1738 | 0 | 2254 | 2468 | 91.3% | -| ov_SC03_111 | 2265 | 1738 | 0 | 2268 | 2510 | 90.4% | -| ov_SC03_112 | 2259 | 1740 | 0 | 2261 | 2526 | 89.5% | -| ov_SC03_113 | 2252 | 1740 | 0 | 2255 | 2468 | 91.4% | -| ov_SC03_114 | 2242 | 1738 | 0 | 2244 | 2415 | 92.9% | -| ov_SC03_115 | 2259 | 1738 | 0 | 2261 | 2472 | 91.5% | -| ov_SC03_116 | 2250 | 1738 | 0 | 2253 | 2438 | 92.4% | -| ov_SC03_117 | 2277 | 1738 | 0 | 2283 | 2557 | 89.3% | -| ov_SC03_118 | 2323 | 1762 | 0 | 2324 | 2685 | 86.6% | -| ov_SC03_119 | 2322 | 1762 | 0 | 2323 | 2685 | 86.5% | -| ov_SC03_121 | 2257 | 1738 | 0 | 2260 | 2459 | 91.9% | -| ov_SC03_124 | 2336 | 1734 | 0 | 2356 | 2741 | 86.0% | -| ov_SC03_125 | 2292 | 1738 | 0 | 2304 | 2588 | 89.0% | -| ov_SC03_126 | 2254 | 1740 | 0 | 2254 | 2423 | 93.0% | -| ov_SC04_000 | 2270 | 1742 | 0 | 2279 | 2546 | 89.5% | -| ov_SC04_002 | 2289 | 1738 | 0 | 2293 | 2636 | 87.0% | -| ov_SC04_003 | 2265 | 1738 | 0 | 2269 | 2502 | 90.7% | -| ov_SC04_004 | 2274 | 1738 | 0 | 2276 | 2558 | 89.0% | -| ov_SC04_005 | 2284 | 1738 | 0 | 2290 | 2612 | 87.7% | -| ov_SC04_006 | 2254 | 1738 | 0 | 2256 | 2454 | 91.9% | -| ov_SC04_007 | 2278 | 1738 | 0 | 2282 | 2569 | 88.8% | -| ov_SC04_008 | 2246 | 1738 | 0 | 2246 | 2415 | 93.0% | -| ov_SC04_009 | 2261 | 1738 | 0 | 2264 | 2441 | 92.7% | -| ov_SC04_010 | 2251 | 1738 | 0 | 2252 | 2419 | 93.1% | -| ov_SC04_011 | 2309 | 1738 | 0 | 2315 | 2803 | 82.6% | -| ov_SC04_012 | 2248 | 1738 | 0 | 2249 | 2420 | 92.9% | -| ov_SC04_015 | 2314 | 1739 | 0 | 2325 | 2611 | 89.0% | -| ov_SC04_016 | 2251 | 1738 | 0 | 2253 | 2440 | 92.3% | -| ov_SC04_018 | 2362 | 1773 | 0 | 2362 | 2857 | 82.7% | -| ov_SC04_019 | 2368 | 1773 | 0 | 2368 | 2857 | 82.9% | -| ov_SC04_020 | 2279 | 1738 | 0 | 2291 | 2567 | 89.2% | -| ov_SC04_021 | 2255 | 1740 | 0 | 2255 | 2423 | 93.1% | -| ov_SC05_000 | 2252 | 1742 | 0 | 2255 | 2422 | 93.1% | -| ov_SC05_001 | 2274 | 1738 | 0 | 2279 | 2574 | 88.5% | -| ov_SC05_002 | 2257 | 1738 | 0 | 2260 | 2442 | 92.5% | -| ov_SC05_003 | 2254 | 1738 | 0 | 2255 | 2481 | 90.9% | -| ov_SC05_004 | 2250 | 1738 | 0 | 2252 | 2464 | 91.4% | -| ov_SC05_005 | 2255 | 1738 | 0 | 2256 | 2491 | 90.6% | -| ov_SC05_006 | 2248 | 1738 | 0 | 2248 | 2430 | 92.5% | -| ov_SC05_007 | 2258 | 1738 | 0 | 2263 | 2482 | 91.2% | -| ov_SC05_008 | 2275 | 1738 | 0 | 2277 | 2543 | 89.5% | -| ov_SC05_009 | 2254 | 1738 | 0 | 2258 | 2438 | 92.6% | -| ov_SC05_010 | 2281 | 1738 | 0 | 2285 | 2588 | 88.3% | -| ov_SC05_011 | 2250 | 1738 | 0 | 2251 | 2409 | 93.4% | -| ov_SC05_017 | 2358 | 1735 | 0 | 2369 | 2842 | 83.4% | -| ov_SC05_018 | 2305 | 1738 | 0 | 2318 | 2673 | 86.7% | -| ov_SC05_019 | 2255 | 1740 | 0 | 2255 | 2423 | 93.1% | -| ov_SC06_000 | 2319 | 1747 | 0 | 2322 | 2691 | 86.3% | -| ov_SC06_006 | 2271 | 1738 | 0 | 2272 | 2511 | 90.5% | -| ov_SC06_008 | 2290 | 1740 | 0 | 2296 | 2542 | 90.3% | -| ov_SC06_010 | 2271 | 1738 | 0 | 2276 | 2517 | 90.4% | -| ov_SC06_011 | 2260 | 1738 | 0 | 2264 | 2468 | 91.7% | -| ov_SC06_013 | 2253 | 1738 | 0 | 2254 | 2425 | 92.9% | -| ov_SC06_014 | 2259 | 1738 | 0 | 2261 | 2453 | 92.2% | -| ov_SC06_015 | 2256 | 1738 | 0 | 2256 | 2421 | 93.2% | -| ov_SC06_016 | 2274 | 1738 | 0 | 2276 | 2549 | 89.3% | -| ov_SC06_018 | 2286 | 1740 | 0 | 2293 | 2665 | 86.0% | -| ov_SC06_020 | 2263 | 1740 | 0 | 2264 | 2518 | 89.9% | -| ov_SC06_022 | 2282 | 1738 | 0 | 2290 | 2642 | 86.7% | -| ov_SC06_024 | 2292 | 1738 | 0 | 2298 | 2667 | 86.2% | -| ov_SC06_025 | 2276 | 1738 | 0 | 2281 | 2572 | 88.7% | -| ov_SC06_027 | 2241 | 1738 | 0 | 2242 | 2408 | 93.1% | -| ov_SC06_029 | 2302 | 1738 | 0 | 2314 | 2662 | 86.9% | -| ov_SC06_030 | 2255 | 1738 | 0 | 2255 | 2456 | 91.8% | -| ov_SC06_032 | 2277 | 1739 | 0 | 2284 | 2658 | 85.9% | -| ov_SC06_033 | 2279 | 1739 | 0 | 2286 | 2631 | 86.9% | -| ov_SC07_000 | 2271 | 1742 | 0 | 2273 | 2521 | 90.2% | -| ov_SC07_001 | 2254 | 1738 | 0 | 2256 | 2454 | 91.9% | -| ov_SC07_002 | 2282 | 1738 | 0 | 2286 | 2579 | 88.6% | +| ov_SC01_001 | 2255 | 1743 | 0 | 2257 | 2466 | 91.5% | +| ov_SC01_004 | 2244 | 1734 | 0 | 2245 | 2414 | 93.0% | +| ov_SC01_005 | 2274 | 1757 | 0 | 2274 | 2503 | 90.9% | +| ov_SC01_006 | 2274 | 1757 | 0 | 2274 | 2503 | 90.9% | +| ov_SC01_008 | 2244 | 1734 | 0 | 2246 | 2426 | 92.6% | +| ov_SC01_009 | 2270 | 1735 | 0 | 2271 | 2507 | 90.6% | +| ov_SC01_074 | 2248 | 1735 | 0 | 2250 | 2425 | 92.8% | +| ov_SC01_077 | 2430 | 1702 | 0 | 2432 | 2585 | 94.1% | +| ov_SC01_080 | 2286 | 1738 | 0 | 2286 | 2512 | 91.0% | +| ov_SC01_084 | 2293 | 1738 | 0 | 2298 | 2579 | 89.1% | +| ov_SC02_000 | 2346 | 1773 | 0 | 2346 | 2683 | 87.4% | +| ov_SC02_003 | 2346 | 1773 | 0 | 2346 | 2683 | 87.4% | +| ov_SC02_004 | 2252 | 1738 | 0 | 2252 | 2401 | 93.8% | +| ov_SC02_005 | 2360 | 1734 | 0 | 2370 | 2927 | 81.0% | +| ov_SC02_011 | 2372 | 1741 | 0 | 2383 | 2893 | 82.4% | +| ov_SC02_015 | 2253 | 1740 | 0 | 2253 | 2414 | 93.3% | +| ov_SC02_016 | 2287 | 1740 | 0 | 2290 | 2545 | 90.0% | +| ov_SC02_017 | 2330 | 1740 | 0 | 2338 | 2732 | 85.6% | +| ov_SC02_021 | 2259 | 1740 | 0 | 2259 | 2437 | 92.7% | +| ov_SC02_026 | 2275 | 1738 | 0 | 2281 | 2572 | 88.7% | +| ov_SC02_027 | 2298 | 1738 | 0 | 2307 | 2692 | 85.7% | +| ov_SC02_028 | 2300 | 1738 | 0 | 2310 | 2701 | 85.5% | +| ov_SC02_031 | 2286 | 1739 | 0 | 2291 | 2562 | 89.4% | +| ov_SC02_035 | 2261 | 1738 | 0 | 2264 | 2520 | 89.8% | +| ov_SC02_039 | 2245 | 1738 | 0 | 2245 | 2416 | 92.9% | +| ov_SC02_041 | 2283 | 1738 | 0 | 2286 | 2561 | 89.3% | +| ov_SC03_001 | 2381 | 1739 | 0 | 2398 | 2869 | 83.6% | +| ov_SC03_002 | 2307 | 1743 | 0 | 2322 | 2631 | 88.3% | +| ov_SC03_003 | 2255 | 1738 | 0 | 2256 | 2423 | 93.1% | +| ov_SC03_006 | 2321 | 1744 | 0 | 2330 | 2767 | 84.2% | +| ov_SC03_007 | 2300 | 1738 | 0 | 2304 | 2623 | 87.8% | +| ov_SC03_010 | 2263 | 1738 | 0 | 2263 | 2471 | 91.6% | +| ov_SC03_011 | 2269 | 1738 | 0 | 2275 | 2527 | 90.0% | +| ov_SC03_012 | 2247 | 1738 | 0 | 2248 | 2406 | 93.4% | +| ov_SC03_013 | 2268 | 1738 | 0 | 2268 | 2493 | 91.0% | +| ov_SC03_014 | 2326 | 1763 | 0 | 2326 | 2685 | 86.6% | +| ov_SC03_015 | 2326 | 1763 | 0 | 2326 | 2685 | 86.6% | +| ov_SC03_023 | 2254 | 1738 | 0 | 2255 | 2435 | 92.6% | +| ov_SC03_024 | 2314 | 1743 | 0 | 2321 | 2641 | 87.9% | +| ov_SC03_028 | 2294 | 1738 | 0 | 2298 | 2664 | 86.3% | +| ov_SC03_029 | 2295 | 1740 | 0 | 2305 | 2644 | 87.2% | +| ov_SC03_030 | 2268 | 1743 | 0 | 2270 | 2495 | 91.0% | +| ov_SC03_031 | 2265 | 1738 | 0 | 2268 | 2514 | 90.2% | +| ov_SC03_089 | 2282 | 1738 | 0 | 2289 | 2581 | 88.7% | +| ov_SC03_090 | 2283 | 1738 | 0 | 2291 | 2625 | 87.3% | +| ov_SC03_091 | 2286 | 1738 | 0 | 2294 | 2640 | 86.9% | +| ov_SC03_092 | 2296 | 1738 | 0 | 2308 | 2587 | 89.2% | +| ov_SC03_093 | 2272 | 1738 | 0 | 2276 | 2563 | 88.8% | +| ov_SC03_094 | 2267 | 1738 | 0 | 2273 | 2577 | 88.2% | +| ov_SC03_095 | 2257 | 1738 | 0 | 2260 | 2474 | 91.4% | +| ov_SC03_096 | 2257 | 1738 | 0 | 2260 | 2465 | 91.7% | +| ov_SC03_097 | 2287 | 1738 | 0 | 2294 | 2603 | 88.1% | +| ov_SC03_098 | 2265 | 1738 | 0 | 2268 | 2541 | 89.3% | +| ov_SC03_099 | 2258 | 1738 | 0 | 2261 | 2504 | 90.3% | +| ov_SC03_100 | 2268 | 1738 | 0 | 2272 | 2539 | 89.5% | +| ov_SC03_101 | 2268 | 1738 | 0 | 2272 | 2528 | 89.9% | +| ov_SC03_102 | 2261 | 1738 | 0 | 2264 | 2492 | 90.9% | +| ov_SC03_103 | 2263 | 1740 | 0 | 2266 | 2510 | 90.3% | +| ov_SC03_104 | 2290 | 1738 | 0 | 2297 | 2616 | 87.8% | +| ov_SC03_105 | 2282 | 1738 | 0 | 2289 | 2597 | 88.1% | +| ov_SC03_108 | 2249 | 1738 | 0 | 2249 | 2443 | 92.1% | +| ov_SC03_109 | 2252 | 1738 | 0 | 2254 | 2424 | 93.0% | +| ov_SC03_110 | 2256 | 1738 | 0 | 2256 | 2468 | 91.4% | +| ov_SC03_111 | 2267 | 1738 | 0 | 2270 | 2510 | 90.4% | +| ov_SC03_112 | 2261 | 1740 | 0 | 2263 | 2526 | 89.6% | +| ov_SC03_113 | 2254 | 1740 | 0 | 2257 | 2468 | 91.5% | +| ov_SC03_114 | 2244 | 1738 | 0 | 2246 | 2415 | 93.0% | +| ov_SC03_115 | 2261 | 1738 | 0 | 2263 | 2472 | 91.5% | +| ov_SC03_116 | 2252 | 1738 | 0 | 2255 | 2438 | 92.5% | +| ov_SC03_117 | 2279 | 1738 | 0 | 2285 | 2557 | 89.4% | +| ov_SC03_118 | 2325 | 1762 | 0 | 2326 | 2685 | 86.6% | +| ov_SC03_119 | 2324 | 1762 | 0 | 2325 | 2685 | 86.6% | +| ov_SC03_121 | 2259 | 1738 | 0 | 2262 | 2459 | 92.0% | +| ov_SC03_124 | 2338 | 1734 | 0 | 2358 | 2741 | 86.0% | +| ov_SC03_125 | 2294 | 1738 | 0 | 2306 | 2588 | 89.1% | +| ov_SC03_126 | 2256 | 1740 | 0 | 2256 | 2423 | 93.1% | +| ov_SC04_000 | 2272 | 1742 | 0 | 2281 | 2546 | 89.6% | +| ov_SC04_002 | 2291 | 1738 | 0 | 2295 | 2636 | 87.1% | +| ov_SC04_003 | 2267 | 1738 | 0 | 2271 | 2502 | 90.8% | +| ov_SC04_004 | 2276 | 1738 | 0 | 2278 | 2558 | 89.1% | +| ov_SC04_005 | 2286 | 1738 | 0 | 2292 | 2612 | 87.7% | +| ov_SC04_006 | 2256 | 1738 | 0 | 2258 | 2454 | 92.0% | +| ov_SC04_007 | 2280 | 1738 | 0 | 2284 | 2569 | 88.9% | +| ov_SC04_008 | 2248 | 1738 | 0 | 2248 | 2415 | 93.1% | +| ov_SC04_009 | 2263 | 1738 | 0 | 2266 | 2441 | 92.8% | +| ov_SC04_010 | 2253 | 1738 | 0 | 2254 | 2419 | 93.2% | +| ov_SC04_011 | 2311 | 1738 | 0 | 2317 | 2803 | 82.7% | +| ov_SC04_012 | 2250 | 1738 | 0 | 2251 | 2420 | 93.0% | +| ov_SC04_015 | 2316 | 1739 | 0 | 2327 | 2611 | 89.1% | +| ov_SC04_016 | 2253 | 1738 | 0 | 2255 | 2440 | 92.4% | +| ov_SC04_018 | 2364 | 1773 | 0 | 2364 | 2857 | 82.7% | +| ov_SC04_019 | 2370 | 1773 | 0 | 2370 | 2857 | 83.0% | +| ov_SC04_020 | 2281 | 1738 | 0 | 2293 | 2567 | 89.3% | +| ov_SC04_021 | 2257 | 1740 | 0 | 2257 | 2423 | 93.1% | +| ov_SC05_000 | 2254 | 1742 | 0 | 2257 | 2422 | 93.2% | +| ov_SC05_001 | 2276 | 1738 | 0 | 2281 | 2574 | 88.6% | +| ov_SC05_002 | 2259 | 1738 | 0 | 2262 | 2442 | 92.6% | +| ov_SC05_003 | 2256 | 1738 | 0 | 2257 | 2481 | 91.0% | +| ov_SC05_004 | 2252 | 1738 | 0 | 2254 | 2464 | 91.5% | +| ov_SC05_005 | 2257 | 1738 | 0 | 2258 | 2491 | 90.6% | +| ov_SC05_006 | 2250 | 1738 | 0 | 2250 | 2430 | 92.6% | +| ov_SC05_007 | 2260 | 1738 | 0 | 2265 | 2482 | 91.3% | +| ov_SC05_008 | 2277 | 1738 | 0 | 2279 | 2543 | 89.6% | +| ov_SC05_009 | 2256 | 1738 | 0 | 2260 | 2438 | 92.7% | +| ov_SC05_010 | 2283 | 1738 | 0 | 2287 | 2588 | 88.4% | +| ov_SC05_011 | 2252 | 1738 | 0 | 2253 | 2409 | 93.5% | +| ov_SC05_017 | 2360 | 1735 | 0 | 2371 | 2842 | 83.4% | +| ov_SC05_018 | 2307 | 1738 | 0 | 2320 | 2673 | 86.8% | +| ov_SC05_019 | 2257 | 1740 | 0 | 2257 | 2423 | 93.1% | +| ov_SC06_000 | 2321 | 1747 | 0 | 2324 | 2691 | 86.4% | +| ov_SC06_006 | 2273 | 1738 | 0 | 2274 | 2511 | 90.6% | +| ov_SC06_008 | 2292 | 1740 | 0 | 2298 | 2542 | 90.4% | +| ov_SC06_010 | 2273 | 1738 | 0 | 2278 | 2517 | 90.5% | +| ov_SC06_011 | 2262 | 1738 | 0 | 2266 | 2468 | 91.8% | +| ov_SC06_013 | 2255 | 1738 | 0 | 2256 | 2425 | 93.0% | +| ov_SC06_014 | 2261 | 1738 | 0 | 2263 | 2453 | 92.3% | +| ov_SC06_015 | 2258 | 1738 | 0 | 2258 | 2421 | 93.3% | +| ov_SC06_016 | 2276 | 1738 | 0 | 2278 | 2549 | 89.4% | +| ov_SC06_018 | 2288 | 1740 | 0 | 2295 | 2665 | 86.1% | +| ov_SC06_020 | 2265 | 1740 | 0 | 2266 | 2518 | 90.0% | +| ov_SC06_022 | 2284 | 1738 | 0 | 2292 | 2642 | 86.8% | +| ov_SC06_024 | 2294 | 1738 | 0 | 2300 | 2667 | 86.2% | +| ov_SC06_025 | 2278 | 1738 | 0 | 2283 | 2572 | 88.8% | +| ov_SC06_027 | 2243 | 1738 | 0 | 2244 | 2408 | 93.2% | +| ov_SC06_029 | 2304 | 1738 | 0 | 2316 | 2662 | 87.0% | +| ov_SC06_030 | 2257 | 1738 | 0 | 2257 | 2456 | 91.9% | +| ov_SC06_032 | 2279 | 1739 | 0 | 2286 | 2658 | 86.0% | +| ov_SC06_033 | 2281 | 1739 | 0 | 2288 | 2631 | 87.0% | +| ov_SC07_000 | 2273 | 1742 | 0 | 2275 | 2521 | 90.2% | +| ov_SC07_001 | 2256 | 1738 | 0 | 2258 | 2454 | 92.0% | +| ov_SC07_002 | 2284 | 1738 | 0 | 2288 | 2579 | 88.7% | | ov_SC07_006 | 2051 | 1555 | 0 | 2131 | 2455 | 86.8% | -| ov_SC07_007 | 2043 | 1586 | 0 | 2127 | 2613 | 81.4% | -| ov_SC07_008 | 2239 | 1738 | 0 | 2239 | 2386 | 93.8% | -| ov_SC07_009 | 2248 | 1738 | 0 | 2250 | 2430 | 92.6% | -| ov_SC07_010 | 2074 | 1608 | 0 | 2157 | 2524 | 85.5% | -| ov_SC07_011 | 2042 | 1585 | 0 | 2122 | 2449 | 86.6% | +| ov_SC07_007 | 2045 | 1586 | 0 | 2129 | 2613 | 81.5% | +| ov_SC07_008 | 2241 | 1738 | 0 | 2241 | 2386 | 93.9% | +| ov_SC07_009 | 2250 | 1738 | 0 | 2252 | 2430 | 92.7% | +| ov_SC07_010 | 2076 | 1608 | 0 | 2159 | 2524 | 85.5% | +| ov_SC07_011 | 2044 | 1585 | 0 | 2124 | 2449 | 86.7% | diff --git a/src/ov_SC01_001/ov_SC01_001_after.c b/src/ov_SC01_001/ov_SC01_001_after.c index a7bc3c807a..e76e11e3c0 100644 --- a/src/ov_SC01_001/ov_SC01_001_after.c +++ b/src/ov_SC01_001/ov_SC01_001_after.c @@ -1371,7 +1371,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_001/nonmatchings/ov_SC01_001_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC01_001/nonmatchings/ov_SC01_001_after", func_8014D2A0); 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 9ad898458d..acc5baa5df 100644 --- a/src/ov_SC01_001/ov_SC01_001_jr_8012ACE0.c +++ b/src/ov_SC01_001/ov_SC01_001_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_001/nonmatchings/ov_SC01_001_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 fe94207552..f70a121e63 100644 --- a/src/ov_SC01_004/ov_SC01_004_after.c +++ b/src/ov_SC01_004/ov_SC01_004_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_004/nonmatchings/ov_SC01_004_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC01_004/nonmatchings/ov_SC01_004_after", func_8014D2A0); 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 adcf101c69..45d4fe4474 100644 --- a/src/ov_SC01_004/ov_SC01_004_jr_8012ACE0.c +++ b/src/ov_SC01_004/ov_SC01_004_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_004/nonmatchings/ov_SC01_004_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 5241063236..1a38fff0c0 100644 --- a/src/ov_SC01_005/ov_SC01_005_after.c +++ b/src/ov_SC01_005/ov_SC01_005_after.c @@ -1306,7 +1306,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_005/nonmatchings/ov_SC01_005_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC01_005/nonmatchings/ov_SC01_005_after", func_8014D2A0); 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 575ccede9f..e17df844aa 100644 --- a/src/ov_SC01_005/ov_SC01_005_jr_8012ACE0.c +++ b/src/ov_SC01_005/ov_SC01_005_jr_8012ACE0.c @@ -528,7 +528,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_005/nonmatchings/ov_SC01_005_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 fa9a9ed29c..162a1531a6 100644 --- a/src/ov_SC01_006/ov_SC01_006_after.c +++ b/src/ov_SC01_006/ov_SC01_006_after.c @@ -1306,7 +1306,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_006/nonmatchings/ov_SC01_006_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC01_006/nonmatchings/ov_SC01_006_after", func_8014D2A0); 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 9de479b579..8045458670 100644 --- a/src/ov_SC01_006/ov_SC01_006_jr_8012ACE0.c +++ b/src/ov_SC01_006/ov_SC01_006_jr_8012ACE0.c @@ -528,7 +528,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_006/nonmatchings/ov_SC01_006_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 12b1167705..946c4eb3e2 100644 --- a/src/ov_SC01_008/ov_SC01_008_after.c +++ b/src/ov_SC01_008/ov_SC01_008_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_008/nonmatchings/ov_SC01_008_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC01_008/nonmatchings/ov_SC01_008_after", func_8014D2A0); 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 ac97a7e5f6..a3a52eb6fa 100644 --- a/src/ov_SC01_008/ov_SC01_008_jr_8012ACE0.c +++ b/src/ov_SC01_008/ov_SC01_008_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_008/nonmatchings/ov_SC01_008_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 78d1548856..065e769a87 100644 --- a/src/ov_SC01_009/ov_SC01_009_after.c +++ b/src/ov_SC01_009/ov_SC01_009_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_009/nonmatchings/ov_SC01_009_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC01_009/nonmatchings/ov_SC01_009_after", func_8014D2A0); 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 5e93109dd8..795512175c 100644 --- a/src/ov_SC01_009/ov_SC01_009_jr_8012ACE0.c +++ b/src/ov_SC01_009/ov_SC01_009_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_009/nonmatchings/ov_SC01_009_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 2fddde50c4..30f50ab43f 100644 --- a/src/ov_SC01_074/ov_SC01_074_after.c +++ b/src/ov_SC01_074/ov_SC01_074_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_074/nonmatchings/ov_SC01_074_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC01_074/nonmatchings/ov_SC01_074_after", func_8014D2A0); 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 14e400f5f3..c7f6a31b0a 100644 --- a/src/ov_SC01_074/ov_SC01_074_jr_8012ACE0.c +++ b/src/ov_SC01_074/ov_SC01_074_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_074/nonmatchings/ov_SC01_074_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 bae00258b5..3ad0ebbc86 100644 --- a/src/ov_SC01_077/ov_SC01_077_after.c +++ b/src/ov_SC01_077/ov_SC01_077_after.c @@ -1497,7 +1497,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_077/nonmatchings/ov_SC01_077_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC01_077/nonmatchings/ov_SC01_077_after", func_8014D2A0); 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 b5b0b0960b..ec021e0043 100644 --- a/src/ov_SC01_077/ov_SC01_077_jr_8012ACE0.c +++ b/src/ov_SC01_077/ov_SC01_077_jr_8012ACE0.c @@ -652,7 +652,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_077/nonmatchings/ov_SC01_077_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 4b3ea04e0b..39e3af8874 100644 --- a/src/ov_SC01_080/ov_SC01_080_after.c +++ b/src/ov_SC01_080/ov_SC01_080_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_after", func_8014D2A0); 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 9f9dd6274f..6b29cd4a6d 100644 --- a/src/ov_SC01_080/ov_SC01_080_jr_8012ACE0.c +++ b/src/ov_SC01_080/ov_SC01_080_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 3c6647579a..ce28a216ac 100644 --- a/src/ov_SC01_084/ov_SC01_084_after.c +++ b/src/ov_SC01_084/ov_SC01_084_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_after", func_8014D2A0); 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 f121fa9aa9..5235e410b9 100644 --- a/src/ov_SC01_084/ov_SC01_084_jr_8012ACE0.c +++ b/src/ov_SC01_084/ov_SC01_084_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 1f853e608e..fe88808500 100644 --- a/src/ov_SC02_000/ov_SC02_000_after.c +++ b/src/ov_SC02_000/ov_SC02_000_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_after", func_8014D2A0); 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 7f1a1cdee6..ba1330c9d5 100644 --- a/src/ov_SC02_000/ov_SC02_000_jr_8012ACE0.c +++ b/src/ov_SC02_000/ov_SC02_000_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 1a585a52b2..6e0b188e1c 100644 --- a/src/ov_SC02_003/ov_SC02_003_after.c +++ b/src/ov_SC02_003/ov_SC02_003_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_after", func_8014D2A0); 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 2cbdbba058..ca8d5ee6b5 100644 --- a/src/ov_SC02_003/ov_SC02_003_jr_8012ACE0.c +++ b/src/ov_SC02_003/ov_SC02_003_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 068ae3e518..fbd4cc82a3 100644 --- a/src/ov_SC02_004/ov_SC02_004_after.c +++ b/src/ov_SC02_004/ov_SC02_004_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_after", func_8014D2A0); 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 fa70fe278a..b36349f37a 100644 --- a/src/ov_SC02_004/ov_SC02_004_jr_8012ACE0.c +++ b/src/ov_SC02_004/ov_SC02_004_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 6233573f0d..0ef6ed61dd 100644 --- a/src/ov_SC02_005/ov_SC02_005_after.c +++ b/src/ov_SC02_005/ov_SC02_005_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_after", func_8014D2A0); 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 2fc231d25a..a6553195d0 100644 --- a/src/ov_SC02_005/ov_SC02_005_jr_8012ACE0.c +++ b/src/ov_SC02_005/ov_SC02_005_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 0cc1b440db..ae3d81630d 100644 --- a/src/ov_SC02_011/ov_SC02_011_after.c +++ b/src/ov_SC02_011/ov_SC02_011_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_after", func_8014D2A0); 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 83bc588b82..5682c8d854 100644 --- a/src/ov_SC02_011/ov_SC02_011_jr_8012ACE0.c +++ b/src/ov_SC02_011/ov_SC02_011_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 2be2d7c208..f72fb01f50 100644 --- a/src/ov_SC02_015/ov_SC02_015_after.c +++ b/src/ov_SC02_015/ov_SC02_015_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_after", func_8014D2A0); 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 2c7680ee6c..43c5752465 100644 --- a/src/ov_SC02_015/ov_SC02_015_jr_8012ACE0.c +++ b/src/ov_SC02_015/ov_SC02_015_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 85f06a4ba5..2900679411 100644 --- a/src/ov_SC02_016/ov_SC02_016_after.c +++ b/src/ov_SC02_016/ov_SC02_016_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_after", func_8014D2A0); 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 4389b0e501..dc3d493e50 100644 --- a/src/ov_SC02_016/ov_SC02_016_jr_8012ACE0.c +++ b/src/ov_SC02_016/ov_SC02_016_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 d9e3c73604..c9091fbc3f 100644 --- a/src/ov_SC02_017/ov_SC02_017_after.c +++ b/src/ov_SC02_017/ov_SC02_017_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_after", func_8014D2A0); 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 dbf99c089b..44bb72f4ec 100644 --- a/src/ov_SC02_017/ov_SC02_017_jr_8012ACE0.c +++ b/src/ov_SC02_017/ov_SC02_017_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 e19937d885..8e3e038928 100644 --- a/src/ov_SC02_021/ov_SC02_021_after.c +++ b/src/ov_SC02_021/ov_SC02_021_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_after", func_8014D2A0); 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 b013de3c27..3e48224fce 100644 --- a/src/ov_SC02_021/ov_SC02_021_jr_8012ACE0.c +++ b/src/ov_SC02_021/ov_SC02_021_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 65d11113fd..5957117b42 100644 --- a/src/ov_SC02_026/ov_SC02_026_after.c +++ b/src/ov_SC02_026/ov_SC02_026_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_after", func_8014D2A0); 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 cdf29ad53c..08a380100c 100644 --- a/src/ov_SC02_026/ov_SC02_026_jr_8012ACE0.c +++ b/src/ov_SC02_026/ov_SC02_026_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 b3a8620313..1212f85b56 100644 --- a/src/ov_SC02_027/ov_SC02_027_after.c +++ b/src/ov_SC02_027/ov_SC02_027_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_after", func_8014D2A0); 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 3a75d623e7..98295d445b 100644 --- a/src/ov_SC02_027/ov_SC02_027_jr_8012ACE0.c +++ b/src/ov_SC02_027/ov_SC02_027_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 c7b5a72b2c..f46d959eba 100644 --- a/src/ov_SC02_028/ov_SC02_028_after.c +++ b/src/ov_SC02_028/ov_SC02_028_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_after", func_8014D2A0); 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 c32f632e6b..340dfa8c21 100644 --- a/src/ov_SC02_028/ov_SC02_028_jr_8012ACE0.c +++ b/src/ov_SC02_028/ov_SC02_028_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 2d2a50cb9c..78e783a60a 100644 --- a/src/ov_SC02_031/ov_SC02_031_after.c +++ b/src/ov_SC02_031/ov_SC02_031_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_after", func_8014D2A0); 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 03c708b60e..336f34ca6e 100644 --- a/src/ov_SC02_031/ov_SC02_031_jr_8012ACE0.c +++ b/src/ov_SC02_031/ov_SC02_031_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 4338ad03b7..7549b31a46 100644 --- a/src/ov_SC02_035/ov_SC02_035_after.c +++ b/src/ov_SC02_035/ov_SC02_035_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_after", func_8014D2A0); 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 daf5a0b751..65f1bb49c3 100644 --- a/src/ov_SC02_035/ov_SC02_035_jr_8012ACE0.c +++ b/src/ov_SC02_035/ov_SC02_035_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 b30b1214c0..c769673746 100644 --- a/src/ov_SC02_039/ov_SC02_039_after.c +++ b/src/ov_SC02_039/ov_SC02_039_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_after", func_8014D2A0); 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 6e8f502ba2..06c79dad46 100644 --- a/src/ov_SC02_039/ov_SC02_039_jr_8012ACE0.c +++ b/src/ov_SC02_039/ov_SC02_039_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 46fb110623..a9dd9d74e2 100644 --- a/src/ov_SC02_041/ov_SC02_041_after.c +++ b/src/ov_SC02_041/ov_SC02_041_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_after", func_8014D2A0); 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 d4bea932a8..1c821e4295 100644 --- a/src/ov_SC02_041/ov_SC02_041_jr_8012ACE0.c +++ b/src/ov_SC02_041/ov_SC02_041_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 cebd423f17..85b75add1b 100644 --- a/src/ov_SC03_001/ov_SC03_001_after.c +++ b/src/ov_SC03_001/ov_SC03_001_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_after", func_8014D2A0); 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 8dcf297856..7e74f54714 100644 --- a/src/ov_SC03_001/ov_SC03_001_jr_8012ACE0.c +++ b/src/ov_SC03_001/ov_SC03_001_jr_8012ACE0.c @@ -533,7 +533,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 128b2cf25e..d63ab030fb 100644 --- a/src/ov_SC03_002/ov_SC03_002_after.c +++ b/src/ov_SC03_002/ov_SC03_002_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_after", func_8014D2A0); 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 05a92738a3..b5dd960337 100644 --- a/src/ov_SC03_002/ov_SC03_002_jr_8012ACE0.c +++ b/src/ov_SC03_002/ov_SC03_002_jr_8012ACE0.c @@ -536,7 +536,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 e892d3f967..fa7a399d34 100644 --- a/src/ov_SC03_003/ov_SC03_003_after.c +++ b/src/ov_SC03_003/ov_SC03_003_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_after", func_8014D2A0); 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 997a3fd250..2fc19b8061 100644 --- a/src/ov_SC03_003/ov_SC03_003_jr_8012ACE0.c +++ b/src/ov_SC03_003/ov_SC03_003_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 fb44ba02ec..ffb23a447a 100644 --- a/src/ov_SC03_006/ov_SC03_006_after.c +++ b/src/ov_SC03_006/ov_SC03_006_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_after", func_8014D2A0); 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 01c72b6118..4df0e3fa16 100644 --- a/src/ov_SC03_006/ov_SC03_006_jr_8012ACE0.c +++ b/src/ov_SC03_006/ov_SC03_006_jr_8012ACE0.c @@ -536,7 +536,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 94b9454afa..7991556e8a 100644 --- a/src/ov_SC03_007/ov_SC03_007_after.c +++ b/src/ov_SC03_007/ov_SC03_007_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_after", func_8014D2A0); 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 a69373a99a..6f0a9a79fc 100644 --- a/src/ov_SC03_007/ov_SC03_007_jr_8012ACE0.c +++ b/src/ov_SC03_007/ov_SC03_007_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 85c402286e..9d4875c2dd 100644 --- a/src/ov_SC03_010/ov_SC03_010_after.c +++ b/src/ov_SC03_010/ov_SC03_010_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_after", func_8014D2A0); 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 498a9363f9..541aeac13b 100644 --- a/src/ov_SC03_010/ov_SC03_010_jr_8012ACE0.c +++ b/src/ov_SC03_010/ov_SC03_010_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 09398cb02c..3f7f025473 100644 --- a/src/ov_SC03_011/ov_SC03_011_after.c +++ b/src/ov_SC03_011/ov_SC03_011_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_after", func_8014D2A0); 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 610db5adc0..46cecad991 100644 --- a/src/ov_SC03_011/ov_SC03_011_jr_8012ACE0.c +++ b/src/ov_SC03_011/ov_SC03_011_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 6d207016f9..95e1497671 100644 --- a/src/ov_SC03_012/ov_SC03_012_after.c +++ b/src/ov_SC03_012/ov_SC03_012_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_after", func_8014D2A0); 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 625ed3c175..9936afbcc2 100644 --- a/src/ov_SC03_012/ov_SC03_012_jr_8012ACE0.c +++ b/src/ov_SC03_012/ov_SC03_012_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 5cfdbb81e5..43a280c731 100644 --- a/src/ov_SC03_013/ov_SC03_013_after.c +++ b/src/ov_SC03_013/ov_SC03_013_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_after", func_8014D2A0); 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 aff93cbc4b..711fd5f8ba 100644 --- a/src/ov_SC03_013/ov_SC03_013_jr_8012ACE0.c +++ b/src/ov_SC03_013/ov_SC03_013_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 f920930d1a..52fc8bf207 100644 --- a/src/ov_SC03_014/ov_SC03_014_after.c +++ b/src/ov_SC03_014/ov_SC03_014_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_after", func_8014D2A0); 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 1fe88e49de..1aaa4683b5 100644 --- a/src/ov_SC03_014/ov_SC03_014_jr_8012ACE0.c +++ b/src/ov_SC03_014/ov_SC03_014_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 29d0b8301b..bcabe22c74 100644 --- a/src/ov_SC03_015/ov_SC03_015_after.c +++ b/src/ov_SC03_015/ov_SC03_015_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_after", func_8014D2A0); 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 f9800b7c35..9a80f9b401 100644 --- a/src/ov_SC03_015/ov_SC03_015_jr_8012ACE0.c +++ b/src/ov_SC03_015/ov_SC03_015_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 db2d159174..75d324f3fa 100644 --- a/src/ov_SC03_023/ov_SC03_023_after.c +++ b/src/ov_SC03_023/ov_SC03_023_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_after", func_8014D2A0); 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 f137a2bdc0..cc6ed04474 100644 --- a/src/ov_SC03_023/ov_SC03_023_jr_8012ACE0.c +++ b/src/ov_SC03_023/ov_SC03_023_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 5d36f54026..151067414b 100644 --- a/src/ov_SC03_024/ov_SC03_024_after.c +++ b/src/ov_SC03_024/ov_SC03_024_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_after", func_8014D2A0); 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 7f4d1be3c5..8c6909f90d 100644 --- a/src/ov_SC03_024/ov_SC03_024_jr_8012ACE0.c +++ b/src/ov_SC03_024/ov_SC03_024_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 63fbb0802a..2d7a8c1d04 100644 --- a/src/ov_SC03_028/ov_SC03_028_after.c +++ b/src/ov_SC03_028/ov_SC03_028_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_after", func_8014D2A0); 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 aaa32d3a92..8a99bd8447 100644 --- a/src/ov_SC03_028/ov_SC03_028_jr_8012ACE0.c +++ b/src/ov_SC03_028/ov_SC03_028_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 d4ad294def..710565133a 100644 --- a/src/ov_SC03_029/ov_SC03_029_after.c +++ b/src/ov_SC03_029/ov_SC03_029_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_after", func_8014D2A0); 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 59ae0503d2..a02fd526c5 100644 --- a/src/ov_SC03_029/ov_SC03_029_jr_8012ACE0.c +++ b/src/ov_SC03_029/ov_SC03_029_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 0cc59db12d..1c56dc33b0 100644 --- a/src/ov_SC03_030/ov_SC03_030_after.c +++ b/src/ov_SC03_030/ov_SC03_030_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_after", func_8014D2A0); 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 3d5cb7ec15..40a1eb3e0b 100644 --- a/src/ov_SC03_030/ov_SC03_030_jr_8012ACE0.c +++ b/src/ov_SC03_030/ov_SC03_030_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 69c9b25607..30ce9d4a93 100644 --- a/src/ov_SC03_031/ov_SC03_031_after.c +++ b/src/ov_SC03_031/ov_SC03_031_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_after", func_8014D2A0); 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 29cf348e8a..5f701eaa91 100644 --- a/src/ov_SC03_031/ov_SC03_031_jr_8012ACE0.c +++ b/src/ov_SC03_031/ov_SC03_031_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 963731d632..68d5c132fc 100644 --- a/src/ov_SC03_089/ov_SC03_089_after.c +++ b/src/ov_SC03_089/ov_SC03_089_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_after", func_8014D2A0); 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 49da9a92eb..2083deaf74 100644 --- a/src/ov_SC03_089/ov_SC03_089_jr_8012ACE0.c +++ b/src/ov_SC03_089/ov_SC03_089_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 3c95554c37..2387c10e62 100644 --- a/src/ov_SC03_090/ov_SC03_090_after.c +++ b/src/ov_SC03_090/ov_SC03_090_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_after", func_8014D2A0); 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 a340fbb3f4..14c2ba4903 100644 --- a/src/ov_SC03_090/ov_SC03_090_jr_8012ACE0.c +++ b/src/ov_SC03_090/ov_SC03_090_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 d84fbccdd2..ee9e185ab4 100644 --- a/src/ov_SC03_091/ov_SC03_091_after.c +++ b/src/ov_SC03_091/ov_SC03_091_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_after", func_8014D2A0); 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 109da5d1c6..5a26b5e0ac 100644 --- a/src/ov_SC03_091/ov_SC03_091_jr_8012ACE0.c +++ b/src/ov_SC03_091/ov_SC03_091_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 00daf3e734..191fb170e8 100644 --- a/src/ov_SC03_092/ov_SC03_092_after.c +++ b/src/ov_SC03_092/ov_SC03_092_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_after", func_8014D2A0); 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 084c7863d6..bc8a6bf582 100644 --- a/src/ov_SC03_092/ov_SC03_092_jr_8012ACE0.c +++ b/src/ov_SC03_092/ov_SC03_092_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 0270edb970..625267e469 100644 --- a/src/ov_SC03_093/ov_SC03_093_after.c +++ b/src/ov_SC03_093/ov_SC03_093_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_after", func_8014D2A0); 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 3e42951ab1..b12a1c6a06 100644 --- a/src/ov_SC03_093/ov_SC03_093_jr_8012ACE0.c +++ b/src/ov_SC03_093/ov_SC03_093_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 28f3a8599b..ef68373a4e 100644 --- a/src/ov_SC03_094/ov_SC03_094_after.c +++ b/src/ov_SC03_094/ov_SC03_094_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_after", func_8014D2A0); 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 de10dc3fc6..c885329da4 100644 --- a/src/ov_SC03_094/ov_SC03_094_jr_8012ACE0.c +++ b/src/ov_SC03_094/ov_SC03_094_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 4747227123..f7b5bc05f1 100644 --- a/src/ov_SC03_095/ov_SC03_095_after.c +++ b/src/ov_SC03_095/ov_SC03_095_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_after", func_8014D2A0); 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 9349b02c6e..002c077027 100644 --- a/src/ov_SC03_095/ov_SC03_095_jr_8012ACE0.c +++ b/src/ov_SC03_095/ov_SC03_095_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 32a331de85..59aa06196f 100644 --- a/src/ov_SC03_096/ov_SC03_096_after.c +++ b/src/ov_SC03_096/ov_SC03_096_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_after", func_8014D2A0); 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 89d193cbec..b024f993a5 100644 --- a/src/ov_SC03_096/ov_SC03_096_jr_8012ACE0.c +++ b/src/ov_SC03_096/ov_SC03_096_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 97ce3df9e4..06a792efce 100644 --- a/src/ov_SC03_097/ov_SC03_097_after.c +++ b/src/ov_SC03_097/ov_SC03_097_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_after", func_8014D2A0); 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 7fbe2e0969..b5414c60b7 100644 --- a/src/ov_SC03_097/ov_SC03_097_jr_8012ACE0.c +++ b/src/ov_SC03_097/ov_SC03_097_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 a16eb97e38..af1e8f26a8 100644 --- a/src/ov_SC03_098/ov_SC03_098_after.c +++ b/src/ov_SC03_098/ov_SC03_098_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_after", func_8014D2A0); 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 f557f24327..3ab635e586 100644 --- a/src/ov_SC03_098/ov_SC03_098_jr_8012ACE0.c +++ b/src/ov_SC03_098/ov_SC03_098_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 aba189a6a6..dc5d3bd63b 100644 --- a/src/ov_SC03_099/ov_SC03_099_after.c +++ b/src/ov_SC03_099/ov_SC03_099_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_after", func_8014D2A0); 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 92a3882903..5ad6c0abbb 100644 --- a/src/ov_SC03_099/ov_SC03_099_jr_8012ACE0.c +++ b/src/ov_SC03_099/ov_SC03_099_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 405e3f24d2..f6a95afa4e 100644 --- a/src/ov_SC03_100/ov_SC03_100_after.c +++ b/src/ov_SC03_100/ov_SC03_100_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_after", func_8014D2A0); 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 d466898fa9..5ba44f756c 100644 --- a/src/ov_SC03_100/ov_SC03_100_jr_8012ACE0.c +++ b/src/ov_SC03_100/ov_SC03_100_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 df028969a2..fa7cdb809e 100644 --- a/src/ov_SC03_101/ov_SC03_101_after.c +++ b/src/ov_SC03_101/ov_SC03_101_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_after", func_8014D2A0); 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 cb85e498fa..fdb0bde7dc 100644 --- a/src/ov_SC03_101/ov_SC03_101_jr_8012ACE0.c +++ b/src/ov_SC03_101/ov_SC03_101_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 21f4d4233d..a9ea9ec97c 100644 --- a/src/ov_SC03_102/ov_SC03_102_after.c +++ b/src/ov_SC03_102/ov_SC03_102_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_after", func_8014D2A0); 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 d35c9a763b..4fda17f488 100644 --- a/src/ov_SC03_102/ov_SC03_102_jr_8012ACE0.c +++ b/src/ov_SC03_102/ov_SC03_102_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 053ca2484e..e68bc91d0d 100644 --- a/src/ov_SC03_103/ov_SC03_103_after.c +++ b/src/ov_SC03_103/ov_SC03_103_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_after", func_8014D2A0); 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 7201d56656..f7c3db3fa3 100644 --- a/src/ov_SC03_103/ov_SC03_103_jr_8012ACE0.c +++ b/src/ov_SC03_103/ov_SC03_103_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 d525fa1496..ed978e2b5e 100644 --- a/src/ov_SC03_104/ov_SC03_104_after.c +++ b/src/ov_SC03_104/ov_SC03_104_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_after", func_8014D2A0); 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 c95119f7ff..1b0eaf4ae0 100644 --- a/src/ov_SC03_104/ov_SC03_104_jr_8012ACE0.c +++ b/src/ov_SC03_104/ov_SC03_104_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 fd02eae3e8..a1b6d9be08 100644 --- a/src/ov_SC03_105/ov_SC03_105_after.c +++ b/src/ov_SC03_105/ov_SC03_105_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_after", func_8014D2A0); 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 70c36e0f42..625c06939a 100644 --- a/src/ov_SC03_105/ov_SC03_105_jr_8012ACE0.c +++ b/src/ov_SC03_105/ov_SC03_105_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 758398a351..29a7474fe3 100644 --- a/src/ov_SC03_108/ov_SC03_108_after.c +++ b/src/ov_SC03_108/ov_SC03_108_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_after", func_8014D2A0); 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 4491715715..8dcc3f3dd5 100644 --- a/src/ov_SC03_108/ov_SC03_108_jr_8012ACE0.c +++ b/src/ov_SC03_108/ov_SC03_108_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 52410ab563..3c03b0ec1c 100644 --- a/src/ov_SC03_109/ov_SC03_109_after.c +++ b/src/ov_SC03_109/ov_SC03_109_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_after", func_8014D2A0); 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 abe462c708..84850d5641 100644 --- a/src/ov_SC03_109/ov_SC03_109_jr_8012ACE0.c +++ b/src/ov_SC03_109/ov_SC03_109_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 47912dbf87..dcaf1c4d6a 100644 --- a/src/ov_SC03_110/ov_SC03_110_after.c +++ b/src/ov_SC03_110/ov_SC03_110_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_after", func_8014D2A0); 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 f98dbab038..d356c0a88c 100644 --- a/src/ov_SC03_110/ov_SC03_110_jr_8012ACE0.c +++ b/src/ov_SC03_110/ov_SC03_110_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 e948161893..ca4caa011c 100644 --- a/src/ov_SC03_111/ov_SC03_111_after.c +++ b/src/ov_SC03_111/ov_SC03_111_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_after", func_8014D2A0); 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 3f26c45a8c..4b0c674c47 100644 --- a/src/ov_SC03_111/ov_SC03_111_jr_8012ACE0.c +++ b/src/ov_SC03_111/ov_SC03_111_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 644985f5ec..075df5c341 100644 --- a/src/ov_SC03_112/ov_SC03_112_after.c +++ b/src/ov_SC03_112/ov_SC03_112_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_after", func_8014D2A0); 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 cb0fc670fc..042a196566 100644 --- a/src/ov_SC03_112/ov_SC03_112_jr_8012ACE0.c +++ b/src/ov_SC03_112/ov_SC03_112_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 944cf4f9c9..a7f9e1dd83 100644 --- a/src/ov_SC03_113/ov_SC03_113_after.c +++ b/src/ov_SC03_113/ov_SC03_113_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_after", func_8014D2A0); 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 f2dc7c4407..ebc4129452 100644 --- a/src/ov_SC03_113/ov_SC03_113_jr_8012ACE0.c +++ b/src/ov_SC03_113/ov_SC03_113_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 99c2f708b5..fcb03fde85 100644 --- a/src/ov_SC03_114/ov_SC03_114_after.c +++ b/src/ov_SC03_114/ov_SC03_114_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_after", func_8014D2A0); 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 ff37282be6..11c57727db 100644 --- a/src/ov_SC03_114/ov_SC03_114_jr_8012ACE0.c +++ b/src/ov_SC03_114/ov_SC03_114_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 d79c3a287f..9ee55a423a 100644 --- a/src/ov_SC03_115/ov_SC03_115_after.c +++ b/src/ov_SC03_115/ov_SC03_115_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_after", func_8014D2A0); 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 e395a3933c..715eaea915 100644 --- a/src/ov_SC03_115/ov_SC03_115_jr_8012ACE0.c +++ b/src/ov_SC03_115/ov_SC03_115_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 0d0df8c970..2b15d22c6f 100644 --- a/src/ov_SC03_116/ov_SC03_116_after.c +++ b/src/ov_SC03_116/ov_SC03_116_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_after", func_8014D2A0); 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 c0fd1fbef1..281ced7f1c 100644 --- a/src/ov_SC03_116/ov_SC03_116_jr_8012ACE0.c +++ b/src/ov_SC03_116/ov_SC03_116_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 d85d572a82..74306ac301 100644 --- a/src/ov_SC03_117/ov_SC03_117_after.c +++ b/src/ov_SC03_117/ov_SC03_117_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_after", func_8014D2A0); 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 ab649c42c6..2c0011307f 100644 --- a/src/ov_SC03_117/ov_SC03_117_jr_8012ACE0.c +++ b/src/ov_SC03_117/ov_SC03_117_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 96415b3429..24202eb9cd 100644 --- a/src/ov_SC03_118/ov_SC03_118_after.c +++ b/src/ov_SC03_118/ov_SC03_118_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_after", func_8014D2A0); 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 d35814ebd4..4dbf4a93c0 100644 --- a/src/ov_SC03_118/ov_SC03_118_jr_8012ACE0.c +++ b/src/ov_SC03_118/ov_SC03_118_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 f0e5a19344..aaaeec8706 100644 --- a/src/ov_SC03_119/ov_SC03_119_after.c +++ b/src/ov_SC03_119/ov_SC03_119_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_after", func_8014D2A0); 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 555d39d074..6d2ac8a27e 100644 --- a/src/ov_SC03_119/ov_SC03_119_jr_8012ACE0.c +++ b/src/ov_SC03_119/ov_SC03_119_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 b5a71102c7..6dc1ab4249 100644 --- a/src/ov_SC03_121/ov_SC03_121_after.c +++ b/src/ov_SC03_121/ov_SC03_121_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_after", func_8014D2A0); 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 c56be99bfa..0d923c089b 100644 --- a/src/ov_SC03_121/ov_SC03_121_jr_8012ACE0.c +++ b/src/ov_SC03_121/ov_SC03_121_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 1eba53ecd5..02b9dae3d1 100644 --- a/src/ov_SC03_124/ov_SC03_124_after.c +++ b/src/ov_SC03_124/ov_SC03_124_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_after", func_8014D2A0); 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 855fe00e04..3e16d0e655 100644 --- a/src/ov_SC03_124/ov_SC03_124_jr_8012ACE0.c +++ b/src/ov_SC03_124/ov_SC03_124_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 c45d2ba7e2..4e75d21beb 100644 --- a/src/ov_SC03_125/ov_SC03_125_after.c +++ b/src/ov_SC03_125/ov_SC03_125_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_after", func_8014D2A0); 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 914a431c5c..169b424ecc 100644 --- a/src/ov_SC03_125/ov_SC03_125_jr_8012ACE0.c +++ b/src/ov_SC03_125/ov_SC03_125_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 50f8c94bf2..80218a14ed 100644 --- a/src/ov_SC03_126/ov_SC03_126_after.c +++ b/src/ov_SC03_126/ov_SC03_126_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_after", func_8014D2A0); 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 53547e907c..8eaec419f5 100644 --- a/src/ov_SC03_126/ov_SC03_126_jr_8012ACE0.c +++ b/src/ov_SC03_126/ov_SC03_126_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 24b5aa46b9..741c807251 100644 --- a/src/ov_SC04_000/ov_SC04_000_after.c +++ b/src/ov_SC04_000/ov_SC04_000_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_after", func_8014D2A0); 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 628daed87c..2ebd0e8135 100644 --- a/src/ov_SC04_000/ov_SC04_000_jr_8012ACE0.c +++ b/src/ov_SC04_000/ov_SC04_000_jr_8012ACE0.c @@ -536,7 +536,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 c011833ff9..b4172c81b1 100644 --- a/src/ov_SC04_002/ov_SC04_002_after.c +++ b/src/ov_SC04_002/ov_SC04_002_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_after", func_8014D2A0); 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 857dc022c5..986f093501 100644 --- a/src/ov_SC04_002/ov_SC04_002_jr_8012ACE0.c +++ b/src/ov_SC04_002/ov_SC04_002_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 80c676647f..d4e569e060 100644 --- a/src/ov_SC04_003/ov_SC04_003_after.c +++ b/src/ov_SC04_003/ov_SC04_003_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_after", func_8014D2A0); 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 6854394709..8af9c48ead 100644 --- a/src/ov_SC04_003/ov_SC04_003_jr_8012ACE0.c +++ b/src/ov_SC04_003/ov_SC04_003_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 e62b1004ec..42b01211d4 100644 --- a/src/ov_SC04_004/ov_SC04_004_after.c +++ b/src/ov_SC04_004/ov_SC04_004_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_after", func_8014D2A0); 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 48d600c773..4442afc4be 100644 --- a/src/ov_SC04_004/ov_SC04_004_jr_8012ACE0.c +++ b/src/ov_SC04_004/ov_SC04_004_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 3d0ad16256..23af61544d 100644 --- a/src/ov_SC04_005/ov_SC04_005_after.c +++ b/src/ov_SC04_005/ov_SC04_005_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_after", func_8014D2A0); 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 6704844390..59880bb9d1 100644 --- a/src/ov_SC04_005/ov_SC04_005_jr_8012ACE0.c +++ b/src/ov_SC04_005/ov_SC04_005_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 a94807ee8b..783d78097b 100644 --- a/src/ov_SC04_006/ov_SC04_006_after.c +++ b/src/ov_SC04_006/ov_SC04_006_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_after", func_8014D2A0); 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 a063f12126..75f972b1ff 100644 --- a/src/ov_SC04_006/ov_SC04_006_jr_8012ACE0.c +++ b/src/ov_SC04_006/ov_SC04_006_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 7c40764eda..e9d38b7360 100644 --- a/src/ov_SC04_007/ov_SC04_007_after.c +++ b/src/ov_SC04_007/ov_SC04_007_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_after", func_8014D2A0); 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 5c43fd9c3f..6b5b694ce5 100644 --- a/src/ov_SC04_007/ov_SC04_007_jr_8012ACE0.c +++ b/src/ov_SC04_007/ov_SC04_007_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 3f1ae4b5c0..4c4a474390 100644 --- a/src/ov_SC04_008/ov_SC04_008_after.c +++ b/src/ov_SC04_008/ov_SC04_008_after.c @@ -1303,7 +1303,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_after", func_8014D2A0); 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 3882c8cad2..878cd62c3b 100644 --- a/src/ov_SC04_008/ov_SC04_008_jr_8012ACE0.c +++ b/src/ov_SC04_008/ov_SC04_008_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 c314a96205..7405ad5460 100644 --- a/src/ov_SC04_009/ov_SC04_009_after.c +++ b/src/ov_SC04_009/ov_SC04_009_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_after", func_8014D2A0); 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 993afa301a..b451decbd6 100644 --- a/src/ov_SC04_009/ov_SC04_009_jr_8012ACE0.c +++ b/src/ov_SC04_009/ov_SC04_009_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 a0a4bf94c9..c5fe779f1c 100644 --- a/src/ov_SC04_010/ov_SC04_010_after.c +++ b/src/ov_SC04_010/ov_SC04_010_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_after", func_8014D2A0); 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 753a1455ad..31c37377af 100644 --- a/src/ov_SC04_010/ov_SC04_010_jr_8012ACE0.c +++ b/src/ov_SC04_010/ov_SC04_010_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 a08f8f37df..527f7ca4ec 100644 --- a/src/ov_SC04_011/ov_SC04_011_after.c +++ b/src/ov_SC04_011/ov_SC04_011_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_after", func_8014D2A0); 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 dbb36fe198..f52312c254 100644 --- a/src/ov_SC04_011/ov_SC04_011_jr_8012ACE0.c +++ b/src/ov_SC04_011/ov_SC04_011_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 add3081077..b3d7408d9c 100644 --- a/src/ov_SC04_012/ov_SC04_012_after.c +++ b/src/ov_SC04_012/ov_SC04_012_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_after", func_8014D2A0); 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 d29bf697e6..d4b6f33809 100644 --- a/src/ov_SC04_012/ov_SC04_012_jr_8012ACE0.c +++ b/src/ov_SC04_012/ov_SC04_012_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 8045d544b3..c30ab492c4 100644 --- a/src/ov_SC04_015/ov_SC04_015_after.c +++ b/src/ov_SC04_015/ov_SC04_015_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_after", func_8014D2A0); 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 6ca638e08c..eff6da7d66 100644 --- a/src/ov_SC04_015/ov_SC04_015_jr_8012ACE0.c +++ b/src/ov_SC04_015/ov_SC04_015_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 115c26e776..1f53fe0643 100644 --- a/src/ov_SC04_016/ov_SC04_016_after.c +++ b/src/ov_SC04_016/ov_SC04_016_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_after", func_8014D2A0); 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 d2f3d10f1c..76ef9b84a8 100644 --- a/src/ov_SC04_016/ov_SC04_016_jr_8012ACE0.c +++ b/src/ov_SC04_016/ov_SC04_016_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 223488ccb8..7948c41f91 100644 --- a/src/ov_SC04_018/ov_SC04_018_after.c +++ b/src/ov_SC04_018/ov_SC04_018_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_after", func_8014D2A0); 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 fc06d08216..434a94faf8 100644 --- a/src/ov_SC04_018/ov_SC04_018_jr_8012ACE0.c +++ b/src/ov_SC04_018/ov_SC04_018_jr_8012ACE0.c @@ -536,7 +536,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 c11eb4ba26..05dbc8b15c 100644 --- a/src/ov_SC04_019/ov_SC04_019_after.c +++ b/src/ov_SC04_019/ov_SC04_019_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_after", func_8014D2A0); 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 a0755b1ec1..df6de14167 100644 --- a/src/ov_SC04_019/ov_SC04_019_jr_8012ACE0.c +++ b/src/ov_SC04_019/ov_SC04_019_jr_8012ACE0.c @@ -536,7 +536,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 6b439cf182..923a9ff9c2 100644 --- a/src/ov_SC04_020/ov_SC04_020_after.c +++ b/src/ov_SC04_020/ov_SC04_020_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_after", func_8014D2A0); 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 4c4ac05e82..4618c7e194 100644 --- a/src/ov_SC04_020/ov_SC04_020_jr_8012ACE0.c +++ b/src/ov_SC04_020/ov_SC04_020_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 246810dc17..19cbe3610f 100644 --- a/src/ov_SC04_021/ov_SC04_021_after.c +++ b/src/ov_SC04_021/ov_SC04_021_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_after", func_8014D2A0); 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 baa6866951..e43151f998 100644 --- a/src/ov_SC04_021/ov_SC04_021_jr_8012ACE0.c +++ b/src/ov_SC04_021/ov_SC04_021_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 16f1fbaadb..cf8122766d 100644 --- a/src/ov_SC05_000/ov_SC05_000_after.c +++ b/src/ov_SC05_000/ov_SC05_000_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_after", func_8014D2A0); 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 9fcd563396..efc79a3394 100644 --- a/src/ov_SC05_000/ov_SC05_000_jr_8012ACE0.c +++ b/src/ov_SC05_000/ov_SC05_000_jr_8012ACE0.c @@ -536,7 +536,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 6b85003af0..11ed982077 100644 --- a/src/ov_SC05_001/ov_SC05_001_after.c +++ b/src/ov_SC05_001/ov_SC05_001_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_after", func_8014D2A0); 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 a522e8248b..3f1c0cb9d5 100644 --- a/src/ov_SC05_001/ov_SC05_001_jr_8012ACE0.c +++ b/src/ov_SC05_001/ov_SC05_001_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 a6b838db52..9df51ca96d 100644 --- a/src/ov_SC05_002/ov_SC05_002_after.c +++ b/src/ov_SC05_002/ov_SC05_002_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_after", func_8014D2A0); 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 9abc1f66d6..d02a1291b7 100644 --- a/src/ov_SC05_002/ov_SC05_002_jr_8012ACE0.c +++ b/src/ov_SC05_002/ov_SC05_002_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 f595383621..b8cbc16ccc 100644 --- a/src/ov_SC05_003/ov_SC05_003_after.c +++ b/src/ov_SC05_003/ov_SC05_003_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_after", func_8014D2A0); 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 07b27a1126..476a4caf0a 100644 --- a/src/ov_SC05_003/ov_SC05_003_jr_8012ACE0.c +++ b/src/ov_SC05_003/ov_SC05_003_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 6a2fa84f02..e32735dc68 100644 --- a/src/ov_SC05_004/ov_SC05_004_after.c +++ b/src/ov_SC05_004/ov_SC05_004_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_after", func_8014D2A0); 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 1840368b48..fbe2c91a8b 100644 --- a/src/ov_SC05_004/ov_SC05_004_jr_8012ACE0.c +++ b/src/ov_SC05_004/ov_SC05_004_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 b93ef1fa74..87fcfc50b9 100644 --- a/src/ov_SC05_005/ov_SC05_005_after.c +++ b/src/ov_SC05_005/ov_SC05_005_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_after", func_8014D2A0); 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 fa9f0508e8..994fd87b42 100644 --- a/src/ov_SC05_005/ov_SC05_005_jr_8012ACE0.c +++ b/src/ov_SC05_005/ov_SC05_005_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 3b0422fe5f..f77081dbc0 100644 --- a/src/ov_SC05_006/ov_SC05_006_after.c +++ b/src/ov_SC05_006/ov_SC05_006_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_after", func_8014D2A0); 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 2727bd0711..1536e8e5e5 100644 --- a/src/ov_SC05_006/ov_SC05_006_jr_8012ACE0.c +++ b/src/ov_SC05_006/ov_SC05_006_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 11e7cc5281..bb8cf2cef2 100644 --- a/src/ov_SC05_007/ov_SC05_007_after.c +++ b/src/ov_SC05_007/ov_SC05_007_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_after", func_8014D2A0); 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 b424e4978e..3a3cc4ecc8 100644 --- a/src/ov_SC05_007/ov_SC05_007_jr_8012ACE0.c +++ b/src/ov_SC05_007/ov_SC05_007_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 e82d0c3310..dae7c9b43c 100644 --- a/src/ov_SC05_008/ov_SC05_008_after.c +++ b/src/ov_SC05_008/ov_SC05_008_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_after", func_8014D2A0); 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 c5b5e8c869..c1fd886b66 100644 --- a/src/ov_SC05_008/ov_SC05_008_jr_8012ACE0.c +++ b/src/ov_SC05_008/ov_SC05_008_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 2f6252349a..6b91ab78f3 100644 --- a/src/ov_SC05_009/ov_SC05_009_after.c +++ b/src/ov_SC05_009/ov_SC05_009_after.c @@ -1303,7 +1303,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_after", func_8014D2A0); 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 030dcef72a..2636a4a430 100644 --- a/src/ov_SC05_009/ov_SC05_009_jr_8012ACE0.c +++ b/src/ov_SC05_009/ov_SC05_009_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 a5425db8b4..999c138f3c 100644 --- a/src/ov_SC05_010/ov_SC05_010_after.c +++ b/src/ov_SC05_010/ov_SC05_010_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_after", func_8014D2A0); 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 a482b9b86e..44436bd200 100644 --- a/src/ov_SC05_010/ov_SC05_010_jr_8012ACE0.c +++ b/src/ov_SC05_010/ov_SC05_010_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 6f44ca3368..6e6f71a1fd 100644 --- a/src/ov_SC05_011/ov_SC05_011_after.c +++ b/src/ov_SC05_011/ov_SC05_011_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_after", func_8014D2A0); 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 f8fdeee7a8..81f3684b66 100644 --- a/src/ov_SC05_011/ov_SC05_011_jr_8012ACE0.c +++ b/src/ov_SC05_011/ov_SC05_011_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 604da7cfd8..d998854133 100644 --- a/src/ov_SC05_017/ov_SC05_017_after.c +++ b/src/ov_SC05_017/ov_SC05_017_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_after", func_8014D2A0); 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 d1e9c91846..74af0168c1 100644 --- a/src/ov_SC05_017/ov_SC05_017_jr_8012ACE0.c +++ b/src/ov_SC05_017/ov_SC05_017_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 0311848fae..4ec96ef5b3 100644 --- a/src/ov_SC05_018/ov_SC05_018_after.c +++ b/src/ov_SC05_018/ov_SC05_018_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_after", func_8014D2A0); 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 7926ae44a3..40af14cb0e 100644 --- a/src/ov_SC05_018/ov_SC05_018_jr_8012ACE0.c +++ b/src/ov_SC05_018/ov_SC05_018_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 e8b66c9e9a..ef6ca028e0 100644 --- a/src/ov_SC05_019/ov_SC05_019_after.c +++ b/src/ov_SC05_019/ov_SC05_019_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_after", func_8014D2A0); 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 c7e1d45a31..d740f8e1c1 100644 --- a/src/ov_SC05_019/ov_SC05_019_jr_8012ACE0.c +++ b/src/ov_SC05_019/ov_SC05_019_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 9e0c3cc7f6..f5937aeaea 100644 --- a/src/ov_SC06_000/ov_SC06_000_after.c +++ b/src/ov_SC06_000/ov_SC06_000_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_after", func_8014D2A0); 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 037adfa287..c32e20379f 100644 --- a/src/ov_SC06_000/ov_SC06_000_jr_8012ACE0.c +++ b/src/ov_SC06_000/ov_SC06_000_jr_8012ACE0.c @@ -536,7 +536,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 a3896c274f..5f244890f0 100644 --- a/src/ov_SC06_006/ov_SC06_006_after.c +++ b/src/ov_SC06_006/ov_SC06_006_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_after", func_8014D2A0); 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 6ebb5f9474..6663df14b6 100644 --- a/src/ov_SC06_006/ov_SC06_006_jr_8012ACE0.c +++ b/src/ov_SC06_006/ov_SC06_006_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 c96a75272c..118b997c69 100644 --- a/src/ov_SC06_008/ov_SC06_008_after.c +++ b/src/ov_SC06_008/ov_SC06_008_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_after", func_8014D2A0); 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 c0486ca52b..13e03c637a 100644 --- a/src/ov_SC06_008/ov_SC06_008_jr_8012ACE0.c +++ b/src/ov_SC06_008/ov_SC06_008_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 5fce57cfee..8ac60ba4c8 100644 --- a/src/ov_SC06_010/ov_SC06_010_after.c +++ b/src/ov_SC06_010/ov_SC06_010_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_after", func_8014D2A0); 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 b86a881dec..6eea4175d0 100644 --- a/src/ov_SC06_010/ov_SC06_010_jr_8012ACE0.c +++ b/src/ov_SC06_010/ov_SC06_010_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 646e310247..a1a00d3777 100644 --- a/src/ov_SC06_011/ov_SC06_011_after.c +++ b/src/ov_SC06_011/ov_SC06_011_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_after", func_8014D2A0); 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 6af18fee03..b067b4f21f 100644 --- a/src/ov_SC06_011/ov_SC06_011_jr_8012ACE0.c +++ b/src/ov_SC06_011/ov_SC06_011_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 13d58d4a6e..5be9f08b9e 100644 --- a/src/ov_SC06_013/ov_SC06_013_after.c +++ b/src/ov_SC06_013/ov_SC06_013_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_after", func_8014D2A0); 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 c46202b086..636f55472a 100644 --- a/src/ov_SC06_013/ov_SC06_013_jr_8012ACE0.c +++ b/src/ov_SC06_013/ov_SC06_013_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 aedb41e1fb..a88749eb44 100644 --- a/src/ov_SC06_014/ov_SC06_014_after.c +++ b/src/ov_SC06_014/ov_SC06_014_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_after", func_8014D2A0); 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 68d0cc46e6..08cf83c288 100644 --- a/src/ov_SC06_014/ov_SC06_014_jr_8012ACE0.c +++ b/src/ov_SC06_014/ov_SC06_014_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 d1fb209b25..98cd51fbdf 100644 --- a/src/ov_SC06_015/ov_SC06_015_after.c +++ b/src/ov_SC06_015/ov_SC06_015_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_after", func_8014D2A0); 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 66a0068241..3f8ea5e941 100644 --- a/src/ov_SC06_015/ov_SC06_015_jr_8012ACE0.c +++ b/src/ov_SC06_015/ov_SC06_015_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 bae73bbdf8..79e401b433 100644 --- a/src/ov_SC06_016/ov_SC06_016_after.c +++ b/src/ov_SC06_016/ov_SC06_016_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_after", func_8014D2A0); 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 34b24d0866..47c331f349 100644 --- a/src/ov_SC06_016/ov_SC06_016_jr_8012ACE0.c +++ b/src/ov_SC06_016/ov_SC06_016_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 33da971db8..94eb72acfc 100644 --- a/src/ov_SC06_018/ov_SC06_018_after.c +++ b/src/ov_SC06_018/ov_SC06_018_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_018/nonmatchings/ov_SC06_018_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_018/nonmatchings/ov_SC06_018_after", func_8014D2A0); 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 7e77710fa8..07609aaced 100644 --- a/src/ov_SC06_018/ov_SC06_018_jr_8012ACE0.c +++ b/src/ov_SC06_018/ov_SC06_018_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_018/nonmatchings/ov_SC06_018_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 b8415fcdb1..6c422fd886 100644 --- a/src/ov_SC06_020/ov_SC06_020_after.c +++ b/src/ov_SC06_020/ov_SC06_020_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_020/nonmatchings/ov_SC06_020_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_020/nonmatchings/ov_SC06_020_after", func_8014D2A0); 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 7bac4257cf..f4eed4c3f7 100644 --- a/src/ov_SC06_020/ov_SC06_020_jr_8012ACE0.c +++ b/src/ov_SC06_020/ov_SC06_020_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_020/nonmatchings/ov_SC06_020_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 b2b18c6e36..668c2a9453 100644 --- a/src/ov_SC06_022/ov_SC06_022_after.c +++ b/src/ov_SC06_022/ov_SC06_022_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_022/nonmatchings/ov_SC06_022_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_022/nonmatchings/ov_SC06_022_after", func_8014D2A0); 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 c885a685c6..4fb0534dbd 100644 --- a/src/ov_SC06_022/ov_SC06_022_jr_8012ACE0.c +++ b/src/ov_SC06_022/ov_SC06_022_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_022/nonmatchings/ov_SC06_022_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 0679805f83..bf0df4d43f 100644 --- a/src/ov_SC06_024/ov_SC06_024_after.c +++ b/src/ov_SC06_024/ov_SC06_024_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_024/nonmatchings/ov_SC06_024_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_024/nonmatchings/ov_SC06_024_after", func_8014D2A0); 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 de4e9b5688..f800d896aa 100644 --- a/src/ov_SC06_024/ov_SC06_024_jr_8012ACE0.c +++ b/src/ov_SC06_024/ov_SC06_024_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_024/nonmatchings/ov_SC06_024_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 1c80e3a346..9e0b720d74 100644 --- a/src/ov_SC06_025/ov_SC06_025_after.c +++ b/src/ov_SC06_025/ov_SC06_025_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_025/nonmatchings/ov_SC06_025_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_025/nonmatchings/ov_SC06_025_after", func_8014D2A0); 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 43d7c28e39..7e4ed56d6d 100644 --- a/src/ov_SC06_025/ov_SC06_025_jr_8012ACE0.c +++ b/src/ov_SC06_025/ov_SC06_025_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_025/nonmatchings/ov_SC06_025_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 5e8649f2d7..bf173b6f80 100644 --- a/src/ov_SC06_027/ov_SC06_027_after.c +++ b/src/ov_SC06_027/ov_SC06_027_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_027/nonmatchings/ov_SC06_027_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_027/nonmatchings/ov_SC06_027_after", func_8014D2A0); 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 3b4462a35c..8b0af8aff5 100644 --- a/src/ov_SC06_027/ov_SC06_027_jr_8012ACE0.c +++ b/src/ov_SC06_027/ov_SC06_027_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_027/nonmatchings/ov_SC06_027_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 159e6231ad..f0284fe1c2 100644 --- a/src/ov_SC06_029/ov_SC06_029_after.c +++ b/src/ov_SC06_029/ov_SC06_029_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_029/nonmatchings/ov_SC06_029_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_029/nonmatchings/ov_SC06_029_after", func_8014D2A0); 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 03b9721c93..e98632cb18 100644 --- a/src/ov_SC06_029/ov_SC06_029_jr_8012ACE0.c +++ b/src/ov_SC06_029/ov_SC06_029_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_029/nonmatchings/ov_SC06_029_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 7235336105..d0c4d277bb 100644 --- a/src/ov_SC06_030/ov_SC06_030_after.c +++ b/src/ov_SC06_030/ov_SC06_030_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_030/nonmatchings/ov_SC06_030_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_030/nonmatchings/ov_SC06_030_after", func_8014D2A0); 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 7417ea54b1..958a72d3c2 100644 --- a/src/ov_SC06_030/ov_SC06_030_jr_8012ACE0.c +++ b/src/ov_SC06_030/ov_SC06_030_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_030/nonmatchings/ov_SC06_030_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 e4321c4fd0..9902403019 100644 --- a/src/ov_SC06_032/ov_SC06_032_after.c +++ b/src/ov_SC06_032/ov_SC06_032_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_032/nonmatchings/ov_SC06_032_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_032/nonmatchings/ov_SC06_032_after", func_8014D2A0); 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 999d03be6f..7f4b34df91 100644 --- a/src/ov_SC06_032/ov_SC06_032_jr_8012ACE0.c +++ b/src/ov_SC06_032/ov_SC06_032_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_032/nonmatchings/ov_SC06_032_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 9cb24f2dd4..19da563f89 100644 --- a/src/ov_SC06_033/ov_SC06_033_after.c +++ b/src/ov_SC06_033/ov_SC06_033_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_033/nonmatchings/ov_SC06_033_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC06_033/nonmatchings/ov_SC06_033_after", func_8014D2A0); 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 cbe4260126..11940c3cea 100644 --- a/src/ov_SC06_033/ov_SC06_033_jr_8012ACE0.c +++ b/src/ov_SC06_033/ov_SC06_033_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC06_033/nonmatchings/ov_SC06_033_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 73fb35f3f5..81947dc641 100644 --- a/src/ov_SC07_000/ov_SC07_000_after.c +++ b/src/ov_SC07_000/ov_SC07_000_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_000/nonmatchings/ov_SC07_000_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC07_000/nonmatchings/ov_SC07_000_after", func_8014D2A0); 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 9a674c3187..c5978c73ab 100644 --- a/src/ov_SC07_000/ov_SC07_000_jr_8012ACE0.c +++ b/src/ov_SC07_000/ov_SC07_000_jr_8012ACE0.c @@ -536,7 +536,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_000/nonmatchings/ov_SC07_000_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 114e3b2093..0713e01392 100644 --- a/src/ov_SC07_001/ov_SC07_001_after.c +++ b/src/ov_SC07_001/ov_SC07_001_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_001/nonmatchings/ov_SC07_001_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC07_001/nonmatchings/ov_SC07_001_after", func_8014D2A0); 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 8c8a3b5e88..aaaa1a932e 100644 --- a/src/ov_SC07_001/ov_SC07_001_jr_8012ACE0.c +++ b/src/ov_SC07_001/ov_SC07_001_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_001/nonmatchings/ov_SC07_001_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 57cc2a408f..16aaa07335 100644 --- a/src/ov_SC07_002/ov_SC07_002_after.c +++ b/src/ov_SC07_002/ov_SC07_002_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_002/nonmatchings/ov_SC07_002_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC07_002/nonmatchings/ov_SC07_002_after", func_8014D2A0); 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 e0bf8b1230..243d5dd140 100644 --- a/src/ov_SC07_002/ov_SC07_002_jr_8012ACE0.c +++ b/src/ov_SC07_002/ov_SC07_002_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_002/nonmatchings/ov_SC07_002_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (src/shared) */ diff --git a/src/ov_SC07_007/ov_SC07_007.c b/src/ov_SC07_007/ov_SC07_007.c index 4a75a5d90a..c47449d7c2 100644 --- a/src/ov_SC07_007/ov_SC07_007.c +++ b/src/ov_SC07_007/ov_SC07_007.c @@ -1079,7 +1079,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012cc40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012cc64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_007/nonmatchings/ov_SC07_007", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012ce2c (src/shared) */ diff --git a/src/ov_SC07_007/ov_SC07_007_jr_80140608.c b/src/ov_SC07_007/ov_SC07_007_jr_80140608.c index acf90b024c..f0be86770e 100644 --- a/src/ov_SC07_007/ov_SC07_007_jr_80140608.c +++ b/src/ov_SC07_007/ov_SC07_007_jr_80140608.c @@ -3538,7 +3538,45 @@ INCLUDE_ASM("asm/ov_SC07_007/nonmatchings/ov_SC07_007_jr_80140608", func_8014D04 DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014d0a4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_007/nonmatchings/ov_SC07_007_jr_80140608", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC07_007/nonmatchings/ov_SC07_007_jr_80140608", func_8014D2A0); diff --git a/src/ov_SC07_008/ov_SC07_008_after.c b/src/ov_SC07_008/ov_SC07_008_after.c index 4e41e05df1..d1c404d9fa 100644 --- a/src/ov_SC07_008/ov_SC07_008_after.c +++ b/src/ov_SC07_008/ov_SC07_008_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_008/nonmatchings/ov_SC07_008_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC07_008/nonmatchings/ov_SC07_008_after", func_8014D2A0); 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 45f5cedcc8..3e1e3548cc 100644 --- a/src/ov_SC07_008/ov_SC07_008_jr_8012ACE0.c +++ b/src/ov_SC07_008/ov_SC07_008_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_008/nonmatchings/ov_SC07_008_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (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 1173006046..2cab31e668 100644 --- a/src/ov_SC07_009/ov_SC07_009_after.c +++ b/src/ov_SC07_009/ov_SC07_009_after.c @@ -1305,7 +1305,45 @@ void func_8014D04C(void) DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014D0A4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_009/nonmatchings/ov_SC07_009_after", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC07_009/nonmatchings/ov_SC07_009_after", func_8014D2A0); 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 2cf93e44be..6e2ec519c8 100644 --- a/src/ov_SC07_009/ov_SC07_009_jr_8012ACE0.c +++ b/src/ov_SC07_009/ov_SC07_009_jr_8012ACE0.c @@ -534,7 +534,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012CC40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012CC64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_009/nonmatchings/ov_SC07_009_jr_8012ACE0", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012CE2C (src/shared) */ diff --git a/src/ov_SC07_010/ov_SC07_010.c b/src/ov_SC07_010/ov_SC07_010.c index 6bdaa45666..f1fccf37ec 100644 --- a/src/ov_SC07_010/ov_SC07_010.c +++ b/src/ov_SC07_010/ov_SC07_010.c @@ -1079,7 +1079,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012cc40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012cc64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_010/nonmatchings/ov_SC07_010", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012ce2c (src/shared) */ diff --git a/src/ov_SC07_010/ov_SC07_010_jr_80140608.c b/src/ov_SC07_010/ov_SC07_010_jr_80140608.c index 667702a890..6f4b7d2375 100644 --- a/src/ov_SC07_010/ov_SC07_010_jr_80140608.c +++ b/src/ov_SC07_010/ov_SC07_010_jr_80140608.c @@ -3043,7 +3043,45 @@ INCLUDE_ASM("asm/ov_SC07_010/nonmatchings/ov_SC07_010_jr_80140608", func_8014D04 DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014d0a4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_010/nonmatchings/ov_SC07_010_jr_80140608", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC07_010/nonmatchings/ov_SC07_010_jr_80140608", func_8014D2A0); diff --git a/src/ov_SC07_011/ov_SC07_011.c b/src/ov_SC07_011/ov_SC07_011.c index 1061b3fed0..d889e42600 100644 --- a/src/ov_SC07_011/ov_SC07_011.c +++ b/src/ov_SC07_011/ov_SC07_011.c @@ -1079,7 +1079,54 @@ DEFINE_func_8012CC40() /* dedup: shared engine-core @0x8012cc40 (src/shared) */ DEFINE_func_8012CC64() /* dedup: shared engine-core @0x8012cc64 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_011/nonmatchings/ov_SC07_011", func_8012CC88); + +extern s32 func_8012CEB0(s32 a0, s32 a1, s32 a2); + +/* a0 = actor/entity base, a1 = mode passed through to func_8012CEB0, a2 = s16[3] offset vector. + * Two 8-byte s16 vectors live at sp+0x10 and sp+0x18 and are passed by address; the second one + * is written back to the entity's hi-16 fixed-point position after the offset is removed. */ +s32 func_8012CC88(s32 a0, s32 a1, s32 a2) { + typedef struct { s16 vx, vy, vz, pad; } SV3_8012CC88; + SV3_8012CC88 sp10; + SV3_8012CC88 sp18; + s32 v0; + + sp10.vx = *(u16*)(a0 + 0x3A); + sp10.vy = *(u16*)(a0 + 0x3E); + sp10.vz = *(u16*)(a0 + 0x42); + sp10.vx += *(u16*)(a2 + 0); + sp10.vy += *(u16*)(a2 + 2); + sp10.vz += *(u16*)(a2 + 4); + + *(s32*)(a0 + 0x10) += *(s32*)(a0 + 0x44); + *(s32*)(a0 + 0x14) += *(s32*)(a0 + 0x48); + *(s32*)(a0 + 0x18) += *(s32*)(a0 + 0x4C); + *(s32*)(a0 + 0x04) += *(s32*)(a0 + 0x10); + *(s32*)(a0 + 0x08) += *(s32*)(a0 + 0x14); + *(s32*)(a0 + 0x0C) += *(s32*)(a0 + 0x18); + + sp18.vx = *(u16*)(a0 + 0x06); + sp18.vy = *(u16*)(a0 + 0x0A); + sp18.vz = *(u16*)(a0 + 0x0E); + sp18.vx += *(u16*)(a2 + 0); + sp18.vy += *(u16*)(a2 + 2); + sp18.vz += *(u16*)(a2 + 4); + + v0 = func_8012CEB0((s32)&sp10, (s32)&sp18, a1); + + sp18.vx -= *(u16*)(a2 + 0); + sp18.vy -= *(u16*)(a2 + 2); + sp18.vz -= *(u16*)(a2 + 4); + *(s16*)(a0 + 0x06) = sp18.vx; + *(s16*)(a0 + 0x0A) = sp18.vy; + *(s16*)(a0 + 0x0E) = sp18.vz; + + if (v0 & 0x6000) { + *(s32*)(a0 + 0x14) = 0; + } + return v0; +} + DEFINE_func_8012CE2C() /* dedup: shared engine-core @0x8012ce2c (src/shared) */ diff --git a/src/ov_SC07_011/ov_SC07_011_jr_80140608.c b/src/ov_SC07_011/ov_SC07_011_jr_80140608.c index 170b71f37f..19b2d12641 100644 --- a/src/ov_SC07_011/ov_SC07_011_jr_80140608.c +++ b/src/ov_SC07_011/ov_SC07_011_jr_80140608.c @@ -3540,7 +3540,45 @@ INCLUDE_ASM("asm/ov_SC07_011/nonmatchings/ov_SC07_011_jr_80140608", func_8014D04 DEFINE_func_8014D0A4() /* dedup: shared engine-core @0x8014d0a4 (src/shared) */ -INCLUDE_ASM("asm/ov_SC07_011/nonmatchings/ov_SC07_011_jr_80140608", func_8014D12C); + +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_8014C918(s32 a0, s32 a1); + +s32 func_8014D12C(s32 arg0, void *a1, void *a2) +{ + u16 *arg1 = (u16 *)a1; + u16 *arg2 = (u16 *)a2; + s32 e; + + arg1[1] -= 3; + arg2[1] += 8; + e = *(s32 *)(arg0 + 0x174); + if ((*(u16 *)e == 0) || ((*(u16 *)(e + 0x5C) & 0x400) == 0) || (*(s32 *)(e + 0x58) == 0) || + (*(s16 *)(e + 0xA) < *(s16 *)(arg0 + 0xA))) { + if (*(u16 *)e != 0) { + *(u8 *)(e + 0x74) = 0; + } + *(s32 *)(arg0 + 0x174) = 0; + return 0; + } + arg1[0] = *(u16 *)(arg0 + 0x98); + arg1[1] = *(u16 *)(arg0 + 0x9A) - 3; + arg1[2] = *(u16 *)(arg0 + 0x9C); + if ((*(u16 *)(e + 0x5C) & 8) != 0) { + arg2[1] = arg1[1] + 0x18; + } + if (func_80135A4C(*(s32 *)(e + 0x20), *(s32 *)(e + 0x58), (s32 *)arg1, (s32)arg2) != 0) { + *(u16 *)(arg0 + 6) = arg2[0]; + *(u16 *)(arg0 + 0xA) = arg2[1]; + *(u16 *)(arg0 + 0xE) = arg2[2]; + *(u16 *)(arg0 + 0x16E) = func_8014C918(arg0, *(u8 *)(e + 0x75)) & 0xFF; + return 1; + } + *(u8 *)(e + 0x74) = 0; + *(s32 *)(arg0 + 0x174) = 0; + return 0; +} + INCLUDE_ASM("asm/ov_SC07_011/nonmatchings/ov_SC07_011_jr_80140608", func_8014D2A0); diff --git a/tools/family_remap.py b/tools/family_remap.py index 67aa3b8b13..acf84e9868 100644 --- a/tools/family_remap.py +++ b/tools/family_remap.py @@ -381,7 +381,9 @@ def remap_hseq_body(from_addr, from_ov, to_ov, to_addr, body): if from_addr != to_addr: table[f"func_{from_addr:08X}"] = f"func_{to_addr:08X}" table.update(imm_map) - return apply_remap(body, table), {"symbol_map": m, "imm_map": imm_map} + body, off_notes = fix_derived_offsets(body, table) # §84, BEFORE the name substitution + return apply_remap(body, table), {"symbol_map": m, "imm_map": imm_map, + "derived_offsets": off_notes} def remap_hseq(from_addr, from_ov, to_ov, to_addr=None): @@ -415,8 +417,10 @@ def remap_hseq(from_addr, from_ov, to_ov, to_addr=None): if from_addr != to_addr: table[f"func_{from_addr:08X}"] = f"func_{to_addr:08X}" table.update(imm_map) + unit, off_notes = fix_derived_offsets(unit, table) # §84, BEFORE the name substitution return apply_remap(unit, table), {"symbol_map": m, "imm_map": imm_map, "unresolved": unresolved, - "n_externs": len(externs), "cf": cf} + "n_externs": len(externs), "cf": cf, + "derived_offsets": off_notes} def symbol_map(addr, from_ov, to_ov, to_addr=None): @@ -616,6 +620,44 @@ def _macro_unit(addr): return None, None +_DERIVED_OFF_RE = re.compile(r'&\s*(D_([0-9A-Fa-f]{8}))\s*\+\s*(0[xX][0-9A-Fa-f]+|\d+)') + + +def fix_derived_offsets(unit, table): + """§84 — recompute `&D_ + ` literals against the MEMBER's own symbol addresses. + + A crack may reach a symbol via a DIFFERENT symbol plus a literal offset, so gcc cannot CSE the two + %hi/%lo pairs into one: + (*(S9 *)&D_801DAA78) = *(S9 *)(&D_801DA998 + 0x20); /* same addr as &D_801DA9B8 */ + The literal is NOT a constant of the algorithm — it is the DISTANCE BETWEEN TWO PER-OVERLAY + SYMBOLS, and that distance differs per overlay. Substituting the NAMES while carrying the literal + through emits a wrong %lo, and `match_one` CANNOT SEE IT (it masks HI16/LO16) — only the + whole-binary gate does, as a ONE-BYTE diff. Measured: exemplar 0x801DA998+0x20 == 0x801DA9B8, but + member 0x801A5778+0x20 == 0x801A5798 while the true member symbol is 0x801A5790 (delta 0x18). + + `unit` is the EXEMPLAR body (pre-substitution) and `table` the exemplar->member symbol map, so both + endpoints resolve here. Returns (unit', notes); notes carries (base, old, new) per site, with + new=None where an endpoint is NOT a mapped symbol — REPORTED, never silently carried (R32: a + silent skip is a defect, and a silent skip is exactly how this survived).""" + notes = [] + + def repl(m): + base_ex, hexs, lit_s = m.group(1), m.group(2), m.group(3) + lit = int(lit_s, 16) if lit_s.lower().startswith('0x') else int(lit_s) + target_ex = "D_%08X" % (int(hexs, 16) + lit) + base_mem, target_mem = table.get(base_ex), table.get(target_ex) + if base_mem is None or target_mem is None: + notes.append((base_ex, lit, None)) # not a symbol-to-symbol distance -> leave as-is + return m.group(0) + new_lit = int(target_mem[2:], 16) - int(base_mem[2:], 16) + notes.append((base_ex, lit, new_lit)) + if new_lit == lit: + return m.group(0) + return m.group(0).replace(lit_s, ("0x%X" % new_lit) if new_lit >= 0 else ("-0x%X" % -new_lit)) + + return _DERIVED_OFF_RE.sub(repl, unit), notes + + def apply_remap(unit, table): """single-pass simultaneous substitution of {source_token: replacement} over unit — each source token is matched once against the ORIGINAL text, so chained/permuted maps (D_A->D_B, D_B->D_C, or @@ -647,6 +689,7 @@ def remap(addr, from_ov, to_ov, to_addr=None, imm_map=None): table[f"func_{addr:08X}"] = f"func_{to_addr:08X}" if imm_map: table.update(imm_map) + unit, _off_notes = fix_derived_offsets(unit, table) # §84, BEFORE the name substitution unit = apply_remap(unit, table) return unit, m