diff --git a/docs/code-cleanup.md b/docs/code-cleanup.md index adc4a235af..7580d7e188 100644 --- a/docs/code-cleanup.md +++ b/docs/code-cleanup.md @@ -47,6 +47,16 @@ make it clearer, add a comment that explains why it looks odd. - edit files in `asm/`; - fix bugs from the original game. +## Fakematches + +A fakematch is code that only steers the compiler: `x++; x--;`, `x = x;`, a +`do { } while (0)` outside a macro, an `if (0)` branch, a dead store. It is +allowed until someone finds the real form, but it needs a comment that starts +with `Fakematch:` and says what it changes, ending at most three lines above +it. `check-cleanup.py` finds the first four shapes without that comment (not +dead stores or `x += 1; x -= 1;`, so mark those yourself). If +removing the trick does not change the code, it is not a fakematch: delete it. + ## Names - **Only name what you can prove.** Good evidence: recovered symbols diff --git a/scripts/check-cleanup.py b/scripts/check-cleanup.py index 7fd21df4ba..8c65979869 100644 --- a/scripts/check-cleanup.py +++ b/scripts/check-cleanup.py @@ -19,6 +19,7 @@ import argparse import ast +import bisect import collections import importlib.util import json @@ -75,6 +76,18 @@ RAW_BYTES = re.compile(r"^(?:const\s+)?(?:u8|s8|(?:un)?signed\s+char|char)\s+(\w+)\s*\[[^\]\n]*\]" r"(?:\s*__asm__\s*\(\s*\"([^\"]*)\"\s*\))?[^=;\n]*=\s*\{([^;]*?)\}\s*;", re.M) RAW_BYTES_MAX = 16 +# Code that only steers the compiler (docs/code-cleanup.md, Fakematches). Each use +# needs a `Fakematch:` comment that ends at most FAKEMATCH_REACH lines above it. +OPERAND = r"\*?[A-Za-z_][\w.\[\]]*(?:->[\w.\[\]]+)*" +STEP = r"(?:(" + OPERAND + r")\s*(\+\+|--)|(\+\+|--)\s*(" + OPERAND + r"))" +FAKEMATCHES = [ + ("x++; x--", re.compile(r"(?])" + STEP + r"\s*;\s*" + STEP + r"\s*;")), + ("x = x", re.compile(r"(?:^|[;{}:)])[ \t]*((?:\*\s*)?\(?" + OPERAND + r"\)?)\s*=\s*" + r"((?:\*\s*)?\(?" + OPERAND + r"\)?)\s*;", re.M)), + ("do { } while (0)", re.compile(r"\bdo\s*\{")), + ("if (0)", re.compile(r"\b(?:if|while)\s*\(\s*0\s*\)")), +] +FAKEMATCH_REACH = 3 SNAKE = re.compile(r"^_*[a-z][a-z0-9_]*$") PLACEHOLDER = re.compile(r"^(?:fun|func|FUN|sub|D|D_L\d\d|FUN_L\d\d|jtbl|text_gap|lbl)_[0-9A-Fa-f]{8}\w*?$") HEXPART = re.compile(r"^(?=[0-9A-Fa-f]*\d)[0-9A-Fa-f]{6,8}$") @@ -187,6 +200,65 @@ def param_names(params: str): # —— Per-file checks (run on changed files) —— +def matching_code(text: str) -> str: + """Blank out preprocessor lines and NON_MATCHING drafts, keeping line numbers.""" + out, stack, cont = [], [], False + for line in text.split("\n"): + s = line.strip() + if cont or s.startswith("#"): + cont = line.rstrip().endswith("\\") + m = re.match(r"#\s*(ifdef|ifndef|if|elif|else|endif)\b(.*)", s) + if m and m.group(1) in ("ifdef", "ifndef", "if"): + draft = "NON_MATCHING" in m.group(2) + stack.append([draft, draft and m.group(1) == "ifdef"]) + elif m and m.group(1) in ("else", "elif") and stack and stack[-1][0]: + stack[-1][1] = not stack[-1][1] + elif m and m.group(1) == "endif" and stack: + stack.pop() + out.append(" " * len(line)) + else: + out.append(" " * len(line) if any(on for _, on in stack) else line) + return "\n".join(out) + + +def check_fakematches(rel: str, raw: str, text: str) -> list[Problem]: + code = matching_code(text) + starts = [0] + [m.end() for m in re.finditer("\n", raw)] + line = lambda pos: bisect.bisect_right(starts, pos) + marks = [(line(m.start()), line(m.end())) for m in re.finditer(r"/\*.*?\*/|//[^\n]*", raw, re.S) + if "Fakematch:" in m.group(0)] + out = [] + for kind, pattern in FAKEMATCHES: + for m in pattern.finditer(code): + if kind == "x++; x--": + first, second = m.group(1) or m.group(4), m.group(5) or m.group(8) + if re.sub(r"\s", "", first) != re.sub(r"\s", "", second) or \ + (m.group(2) or m.group(3)) == (m.group(6) or m.group(7)): + continue + elif kind == "x = x": + if re.sub(r"\s", "", m.group(1)) != re.sub(r"\s", "", m.group(2)): + continue + elif kind == "do { } while (0)": + depth, i = 0, m.end() - 1 + for i in range(m.end() - 1, len(code)): + depth += {"{": 1, "}": -1}.get(code[i], 0) + if depth == 0: + break + if not re.match(r"\}\s*while\s*\(\s*0\s*\)\s*;", code[i:i + 40]): + continue + elif m.group(0).startswith("while") and re.search(r"\}\s*$", code[max(0, m.start() - 20):m.start()]): + continue # the end of a do { } while (0) + pos = m.start() + len(m.group(0)) - len(m.group(0).lstrip(";{}:) \t\n")) + at = line(pos) + if any(start <= at and at - end <= FAKEMATCH_REACH for start, end in marks): + continue + snippet = re.sub(r"\s+", " ", code[pos:m.end()]).strip()[:60] + out.append(Problem("fakematch", rel, f"{kind}: `{snippet}` only steers the compiler; " + "say why in a `Fakematch:` comment just above it", at, + f"{kind} {re.sub(chr(32), '', snippet)}")) + return out + + def check_c_file(rel: str, raw: str) -> list[Problem]: out: list[Problem] = [] text = strip_comments(raw) @@ -247,6 +319,8 @@ def check_c_file(rel: str, raw: str) -> list[Problem]: if REGISTER_NAME.match(name): out.append(Problem("register-name", rel, f"local '{name}' is named after a register or a " "decompiler temp; name it by what it holds", line_of(text, m.start()))) + if rel.endswith(".c") and not is_sdk(rel): + out += check_fakematches(rel, raw, text) return out diff --git a/scripts/test_public_tools.py b/scripts/test_public_tools.py index aa8c76aefb..f4bb2d1c5e 100755 --- a/scripts/test_public_tools.py +++ b/scripts/test_public_tools.py @@ -2107,6 +2107,32 @@ def test_raw_bytes_in_c_fail(self): self.assertNotIn("message", out) self.assertNotIn("small_table", out) + def test_fakematch_needs_a_comment(self): + self.write("src/new_helper.c", textwrap.dedent("""\ + #define ONCE(x) do { x; } while (0) + void new_helper(s32 count) __asm__("FUN_00100100"); + void new_helper(s32 count) { + count++; + count--; + ONCE(count = 1); + do { + count = 2; + } while (0); + /* Fakematch: the pair keeps count in its own register. */ + count--; + count++; + #ifndef NON_MATCHING + #else + count = count; + #endif + } + """)) + code, out = self.check() + self.assertEqual(code, 1) + self.assertIn("src/new_helper.c:4: [fakematch] x++; x--", out) + self.assertIn("src/new_helper.c:7: [fakematch] do { } while (0)", out) + self.assertEqual(out.count("[fakematch]"), 2) + def test_recovered_names_format_and_config(self): entry = {"unit": "missing", "source_path": "src/missing.c", "address": "0x00100000", "current_name": "FUN_00100000", "proposed_name": "OldHelper", "logical_group": "EE/x", diff --git a/src/audio/decoder/audio_dec_start.c b/src/audio/decoder/audio_dec_start.c index c9e4299751..2e17e32411 100644 --- a/src/audio/decoder/audio_dec_start.c +++ b/src/audio/decoder/audio_dec_start.c @@ -15,9 +15,8 @@ void audio_dec_start(struct AudioDec *dec) { snd_start_movie_sound(dec->iopBuff, ((copy = temp_2_10) / 0x400) * four, dec->iopZero, dec->hdr.rate, u18); dec->state = 2; - /* Allocator-shape pair: GCC removes both stores (code-dead), but the - read-modify-write sequence drives hdr.ch's register choice to retail's - schedule. Verified 100/100/100 bytes. */ + /* Fakematch: GCC removes both stores, but the read-modify-write + sequence gives hdr.ch retail's register. */ dec->hdr.ch++; dec->hdr.ch--; } diff --git a/src/audio/streaming/snd_play_vag_stream_by_loc_ex_cb.c b/src/audio/streaming/snd_play_vag_stream_by_loc_ex_cb.c index 0c7684058c..5215e505c2 100644 --- a/src/audio/streaming/snd_play_vag_stream_by_loc_ex_cb.c +++ b/src/audio/streaming/snd_play_vag_stream_by_loc_ex_cb.c @@ -20,6 +20,7 @@ void snd_play_vag_stream_by_loc_ex_cb(s32 loc, s32 size, s32 vol_l, s32 vol_r, s int new_var; s32 buf[7]; new_var = (pitch << 16) | (vol_l & 0xFFFF); + /* Fakematch: the dead id update moves the packet stores into retail's order. */ id++; id--; buf[0] = loc; diff --git a/src/math/classify_float_bits.c b/src/math/classify_float_bits.c index a1c8af659e..b4736fc14e 100644 --- a/src/math/classify_float_bits.c +++ b/src/math/classify_float_bits.c @@ -1,6 +1,5 @@ #include "types.h" -/* fdlibm s_isnan.c: EXTRACT_WORDS() as a do { ... } while (0) macro body */ typedef union { f64 value; struct { @@ -9,17 +8,21 @@ typedef union { } parts; } ieee_double_shape_type; +/* fdlibm math_private.h */ +#define EXTRACT_WORDS(ix0, ix1, d) \ + do { \ + ieee_double_shape_type ew_u; \ + ew_u.value = (d); \ + (ix0) = ew_u.parts.msw; \ + (ix1) = ew_u.parts.lsw; \ + } while (0) + s32 classify_double_nan(f64 x) __asm__("ClassifyDoubleNaN"); s32 classify_double_nan(f64 x) { s32 hx; s32 lx; - ieee_double_shape_type ew_u; - do { - ew_u.value = x; - hx = ew_u.parts.msw; - lx = ew_u.parts.lsw; - } while (0); + EXTRACT_WORDS(hx, lx, x); hx &= 0x7fffffff; hx |= (u32)(lx | (-lx)) >> 31; hx = 0x7ff00000 - hx; diff --git a/src/math/geometry/point_is_clockwise.c b/src/math/geometry/point_is_clockwise.c index 20bc1b6390..4a2f0197a1 100644 --- a/src/math/geometry/point_is_clockwise.c +++ b/src/math/geometry/point_is_clockwise.c @@ -11,6 +11,7 @@ int point_is_clockwise(int a0, int a1, int a2, int a3, int t0, int t1) { dx = a0 - a2; dy = a1 - a3; + /* Fakematch: the block keeps the two differences below dx and dy. */ do { int term1 = (t0 - a2) * dy; int term2 = (t1 - a3) * dx; diff --git a/src/math/rotations/extract_matrix_rotation_quaternion.c b/src/math/rotations/extract_matrix_rotation_quaternion.c index ad8dac497e..f2e9f66fcc 100644 --- a/src/math/rotations/extract_matrix_rotation_quaternion.c +++ b/src/math/rotations/extract_matrix_rotation_quaternion.c @@ -10,11 +10,11 @@ void extract_matrix_rotation_quaternion(s32 arg0, s32 arg1) { buf = sp_slot; copy_matrix_rotation(buf); - /* The single-iteration do/while wrappers are allocator-shape levers: - both compile to plain calls (code-identical) but select retail's - callee-saved register roles. */ + /* Fakematch: the single-iteration do/while wrappers compile to plain + calls but select retail's callee-saved register roles. */ do { matrix_to_quaternion(arg0, sp_slot); + /* Fakematch: see above. */ do { copy_matrix3x4(arg1, sp_slot); } while (0); diff --git a/src/overlays/l03/gameplay/entities/taxi.c b/src/overlays/l03/gameplay/entities/taxi.c index 4c902cba72..3a1fa20aae 100644 --- a/src/overlays/l03/gameplay/entities/taxi.c +++ b/src/overlays/l03/gameplay/entities/taxi.c @@ -1336,15 +1336,17 @@ void FUN_L03_002da870(struct Moby *m) { D_L03_001BA6D0.collected[(s16)((struct Moby *)((v->reward << 8) + D_L03_0015FFD8_i))->save_id] = ((struct Moby *)((v->reward << 8) + D_L03_0015FFD8_i))->mission + 2; o = (struct Moby *)((v->reward << 8) + D_L03_0015FFD8_i); - /* Same record as the || test in the level's other reward code; the - do/while (0) blocks keep the loop notes that make gcc predict the - 0xFF branch taken and keep the group load ahead of the table load. */ + /* Fakematch: same record as the || test in the level's other reward + code; the do/while (0) blocks keep the loop notes that make gcc + predict the 0xFF branch taken and keep the group load ahead of the + table load. */ if (o->mission == 0xFF) goto record; do { group = o->mission; } while (0); if (D_L03_0015FC88[group] != 0xFF && D_0014C050[group + current_level_index * 16] == 0xFF) { + /* Fakematch: see above. */ do { record: D_L03_001BB330.collected[(s16)o->save_id] = o->mission + 2; @@ -1732,8 +1734,8 @@ void FUN_L03_002db558(struct Moby *m) { D_L03_001BA6D0.collected[(s16)((struct Moby *)((v->reward << 8) + D_L03_0015FFD8_i))->save_id] = ((struct Moby *)((v->reward << 8) + D_L03_0015FFD8_i))->mission + 2; o = (struct Moby *)((v->reward << 8) + D_L03_0015FFD8_i); - /* Same record test as above; the goto and the do/while (0) loop note keep - the group byte's zero-extend ahead of the table address. */ + /* Fakematch: same record test as above; the goto and the do/while (0) + loop note keep the group byte's zero-extend ahead of the table address. */ if (o->mission == 0xFF) goto rec2; do { diff --git a/src/overlays/l03/gameplay/hero/00205830.c b/src/overlays/l03/gameplay/hero/00205830.c index b02610cbae..d9b05eb915 100644 --- a/src/overlays/l03/gameplay/hero/00205830.c +++ b/src/overlays/l03/gameplay/hero/00205830.c @@ -375,11 +375,7 @@ void FUN_L03_0020ef60(void) { if (hero.unk20A9 != 0) { FUN_L00_00209540(0xF, 0x1E); } - if (0) { - FUN_L00_002132b8(0.7f, frame_time * 0.0f); - } else { - FUN_L00_002132b8(0.5f, frame_time * 2.0f); - } + FUN_L00_002132b8(0.5f, frame_time * 2.0f); FUN_L00_00217118(3.7f, 0.0f); stick_target(1.0f, 0); if (hero.state.current == HERO_STATE_LOOK || hero.state.current == 0x1E) { @@ -461,11 +457,7 @@ void FUN_L03_0020ef60(void) { } } } else if (hero.state.current == HERO_STATE_CROUCH) { - if (0) { - speed = frame_time_sq * 1.7f; - } else { - speed = frame_time_sq * 6.48f; - } + speed = frame_time_sq * 6.48f; } else { speed = frame_time_sq * 12.6f; } @@ -1188,32 +1180,17 @@ void FUN_L03_0020ef60(void) { hero.items[0].timer = 2; } hero.target_speed = 0.0f; - if (0) { - if (MV(hero.unkA54) != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &MV(hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = frame_time * 4.5f; - } - speed_step(frame_time_sq * 4.0f, frame_time_sq * 4.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - speed_step(frame_time_sq * 2.0f, frame_time_sq * 2.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + if (MV(hero.unkA54) != NULL) { + f32 d = FUN_001f9b80(&hero.motion.pos, &MV(hero.unkA54)->u10.v10); + if (d > 2.0f && d < 5.0f) { + hero.target_speed = frame_time * 4.5f; + } + speed_step(frame_time_sq * 25.0f, frame_time_sq * 25.0f); + hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; + hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; } else { - if (MV(hero.unkA54) != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &MV(hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = frame_time * 4.5f; - } - speed_step(frame_time_sq * 25.0f, frame_time_sq * 25.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - speed_step(frame_time_sq * 15.0f, frame_time_sq * 15.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + speed_step(frame_time_sq * 15.0f, frame_time_sq * 15.0f); + FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); } if (hero.unkA58 != 0 || MV(hero.unkA54) != NULL) { hero.motion.move_yaw = hero.unkA5C; @@ -1307,35 +1284,17 @@ void FUN_L03_0020ef60(void) { } FUN_L00_00217658(); } - if (0) { - if (FUN_L00_00211870(84.0f) != 0) { - f32 a = fast_add_rotations(hero.motion.rot.f[2], 3.1415927f); - f32 s = frame_time * 2.5f; - if (pad_held[0] & 0xA) { - s = frame_time * 3.0f; - } - hero.motion.velocity.f[0] += fast_cos(a) * s; - hero.motion.velocity.f[1] += fast_sin(a) * s; - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + speed_step(frame_time_sq * 37.0f, frame_time_sq * 28.0f); + set_planar_vel(99999.0f); + if (hero.air_frames.s != 0) { + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); } else { - speed_step(frame_time_sq * 37.0f, frame_time_sq * 28.0f); - set_planar_vel(99999.0f); - if (hero.air_frames.s != 0) { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); - } else { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); - } + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); } break; } case 0x13: { struct HeroTableRow2C *tb; - if (0) { - FUN_L00_002167d0(); - break; - } if (hero.unkA9C != 0 || hero.anim_frame < D_L03_0017BD28[hero.attack_record].f20) { hero.items[0].timer = 2; } @@ -1462,22 +1421,13 @@ void FUN_L03_0020ef60(void) { FUN_L00_00262528(&hero.trail.pos[0], 0xC, 6); } FUN_L00_00262608(&hero.trail.pos[0], t2 < hero.state_timer ? 5 : 0); - if (0) { - if (t1 < hero.state_timer && hero.state_timer < t1 + scale_game_frames(7) && hero.motion.unk168 < frame_time * 8.5f) { - hero.motion.velocity.f[0] += fast_cos(hero.motion.rot.f[2]) * (frame_time * 1.2f); - hero.motion.velocity.f[1] += fast_sin(hero.motion.rot.f[2]) * (frame_time * 1.2f); - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + if (t1 < hero.state_timer) { + speed_step(frame_time_sq * 190.0f, frame_time_sq * 90.0f); + } + if (hero.unkA58 != 0) { + set_planar_vel(hero.unkA5C); } else { - if (t1 < hero.state_timer) { - speed_step(frame_time_sq * 190.0f, frame_time_sq * 90.0f); - } - if (hero.unkA58 != 0) { - set_planar_vel(hero.unkA5C); - } else { - set_planar_vel(99999.0f); - } + set_planar_vel(99999.0f); } if (hero.state.current == 0x20 && t1 < hero.state_timer && hero.state_timer < t2 + scale_game_frames(4)) { struct MobyView *o = MV(hero.items[0].moby); @@ -1668,6 +1618,7 @@ void FUN_L03_0020ef60(void) { if (hero.motion.velocity.f[2] > frame_time_sq * -40.0f) { hero.motion.velocity.f[2] = frame_time_sq * -40.0f; } + /* Fakematch: cc1 drops the self-store, but it puts frame_time in $f2 as in retail. */ hero.target_speed = hero.target_speed; if (d > frame_time * 1.3962634f) { d = frame_time * 1.3962634f; @@ -1882,12 +1833,6 @@ void FUN_L03_0020ef60(void) { if (hero.unk229C < 0.2f) { g = frame_time_sq * 3.5f; } - if (0) { - g = frame_time_sq * 3.7f; - if (hero.unk229C < 0.2f) { - g = frame_time_sq * 1.2f; - } - } air_accel(g); } FUN_L00_00215340(); diff --git a/src/overlays/l05/gameplay/hero/00244a70.c b/src/overlays/l05/gameplay/hero/00244a70.c index a0bbec499c..8c1a0280a9 100644 --- a/src/overlays/l05/gameplay/hero/00244a70.c +++ b/src/overlays/l05/gameplay/hero/00244a70.c @@ -341,11 +341,7 @@ void FUN_L05_00244a70(void) { if (hero.unk20A9 != 0) { FUN_L00_00209540(0xF, 0x1E); } - if (0) { - FUN_L00_002132b8(0.7f, frame_time * 0.0f); - } else { - FUN_L00_002132b8(0.5f, frame_time * 2.0f); - } + FUN_L00_002132b8(0.5f, frame_time * 2.0f); FUN_L00_00217118(3.7f, 0.0f); stick_target(1.0f, 0); if (hero.state.current == HERO_STATE_LOOK || hero.state.current == 0x1E) { @@ -427,11 +423,7 @@ void FUN_L05_00244a70(void) { } } } else if (hero.state.current == HERO_STATE_CROUCH) { - if (0) { - speed = frame_time_sq * 1.7f; - } else { - speed = frame_time_sq * 6.48f; - } + speed = frame_time_sq * 6.48f; } else { speed = frame_time_sq * 12.6f; } @@ -1432,32 +1424,17 @@ void FUN_L05_00244a70(void) { hero.items[0].timer = 2; } hero.target_speed = 0.0f; - if (0) { - if ((struct MobyView *)hero.unkA54 != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &((struct MobyView *)hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = frame_time * 4.5f; - } - speed_step(frame_time_sq * 4.0f, frame_time_sq * 4.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - speed_step(frame_time_sq * 2.0f, frame_time_sq * 2.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + if ((struct MobyView *)hero.unkA54 != NULL) { + f32 d = FUN_001f9b80(&hero.motion.pos, &((struct MobyView *)hero.unkA54)->u10.v10); + if (d > 2.0f && d < 5.0f) { + hero.target_speed = frame_time * 4.5f; + } + speed_step(frame_time_sq * 25.0f, frame_time_sq * 25.0f); + hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; + hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; } else { - if ((struct MobyView *)hero.unkA54 != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &((struct MobyView *)hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = frame_time * 4.5f; - } - speed_step(frame_time_sq * 25.0f, frame_time_sq * 25.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - speed_step(frame_time_sq * 15.0f, frame_time_sq * 15.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + speed_step(frame_time_sq * 15.0f, frame_time_sq * 15.0f); + FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); } if (hero.unkA58 != 0 || (struct MobyView *)hero.unkA54 != NULL) { hero.motion.move_yaw = hero.unkA5C; @@ -1551,35 +1528,17 @@ void FUN_L05_00244a70(void) { } FUN_L00_00217658(); } - if (0) { - if (FUN_L00_00211870(84.0f) != 0) { - f32 a = fast_add_rotations(hero.motion.rot.f[2], 3.1415927f); - f32 s = frame_time * 2.5f; - if (pad_held[0] & 0xA) { - s = frame_time * 3.0f; - } - hero.motion.velocity.f[0] += fast_cos(a) * s; - hero.motion.velocity.f[1] += fast_sin(a) * s; - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + speed_step(frame_time_sq * 37.0f, frame_time_sq * 28.0f); + set_planar_vel(99999.0f); + if (hero.air_frames.s != 0) { + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); } else { - speed_step(frame_time_sq * 37.0f, frame_time_sq * 28.0f); - set_planar_vel(99999.0f); - if (hero.air_frames.s != 0) { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); - } else { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); - } + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); } break; } case 0x13: { struct HeroTableRow2C *tb; - if (0) { - FUN_L00_002167d0(); - break; - } if (hero.unkA9C != 0 || hero.anim_frame < D_L05_0017C088[hero.attack_record].f20) { hero.items[0].timer = 2; } @@ -1706,22 +1665,13 @@ void FUN_L05_00244a70(void) { FUN_L00_00262528(&hero.trail.pos[0], 0xC, 6); } FUN_L00_00262608(&hero.trail.pos[0], t2 < hero.state_timer ? 5 : 0); - if (0) { - if (t1 < hero.state_timer && hero.state_timer < t1 + scale_game_frames(7) && hero.motion.unk168 < frame_time * 8.5f) { - hero.motion.velocity.f[0] += fast_cos(hero.motion.rot.f[2]) * (frame_time * 1.2f); - hero.motion.velocity.f[1] += fast_sin(hero.motion.rot.f[2]) * (frame_time * 1.2f); - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + if (t1 < hero.state_timer) { + speed_step(frame_time_sq * 190.0f, frame_time_sq * 90.0f); + } + if (hero.unkA58 != 0) { + set_planar_vel(hero.unkA5C); } else { - if (t1 < hero.state_timer) { - speed_step(frame_time_sq * 190.0f, frame_time_sq * 90.0f); - } - if (hero.unkA58 != 0) { - set_planar_vel(hero.unkA5C); - } else { - set_planar_vel(99999.0f); - } + set_planar_vel(99999.0f); } if (hero.state.current == 0x20 && t1 < hero.state_timer && hero.state_timer < t2 + scale_game_frames(4)) { struct MobyView *o = (struct MobyView *)hero.items[0].moby; @@ -1912,6 +1862,7 @@ void FUN_L05_00244a70(void) { if (hero.motion.velocity.f[2] > frame_time_sq * -40.0f) { hero.motion.velocity.f[2] = frame_time_sq * -40.0f; } + /* Fakematch: cc1 drops the self-store, but it puts frame_time in $f2 as in retail. */ hero.target_speed = hero.target_speed; if (d > frame_time * 1.3962634f) { d = frame_time * 1.3962634f; @@ -2367,12 +2318,6 @@ void FUN_L05_00244a70(void) { if (hero.unk229C < 0.2f) { g = frame_time_sq * 3.5f; } - if (0) { - g = frame_time_sq * 3.7f; - if (hero.unk229C < 0.2f) { - g = frame_time_sq * 1.2f; - } - } air_accel(g); } FUN_L00_00215340(); diff --git a/src/overlays/l06/gameplay/hero/00222fb8.c b/src/overlays/l06/gameplay/hero/00222fb8.c index f23486db8c..c69816dcb1 100644 --- a/src/overlays/l06/gameplay/hero/00222fb8.c +++ b/src/overlays/l06/gameplay/hero/00222fb8.c @@ -1031,11 +1031,7 @@ void FUN_L06_0022e020(void) { case 0x71: case 0x72: case 0x80: - if (0) { - FUN_L00_002132b8(0.7f, D_0015ED6C_c * 0.0f); - } else { - FUN_L00_002132b8(0.5f, D_0015ED6C_c * 2.0f); - } + FUN_L00_002132b8(0.5f, D_0015ED6C_c * 2.0f); FUN_L00_00217118(3.7f, 0.0f); FUN_L00_002118c8_c(1.0f, 0); if (hero.state.current == HERO_STATE_LOOK || hero.state.current == 0x1E) { @@ -1117,11 +1113,7 @@ void FUN_L06_0022e020(void) { } } } else if (hero.state.current == HERO_STATE_CROUCH) { - if (0) { - speed = frame_time_sq * 1.7f; - } else { - speed = frame_time_sq * 6.48f; - } + speed = frame_time_sq * 6.48f; } else { speed = frame_time_sq * 12.6f; } @@ -1487,32 +1479,17 @@ void FUN_L06_0022e020(void) { hero.items[0].timer = 2; } hero.target_speed = 0.0f; - if (0) { - if ((struct MobyView *)hero.unkA54 != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &((struct MobyView *)hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = D_0015ED6C_c * 4.5f; - } - FUN_L00_00212088(frame_time_sq * 4.0f, frame_time_sq * 4.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - FUN_L00_00212088(frame_time_sq * 2.0f, frame_time_sq * 2.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + if ((struct MobyView *)hero.unkA54 != NULL) { + f32 d = FUN_001f9b80(&hero.motion.pos, &((struct MobyView *)hero.unkA54)->u10.v10); + if (d > 2.0f && d < 5.0f) { + hero.target_speed = D_0015ED6C_c * 4.5f; + } + FUN_L00_00212088(frame_time_sq * 25.0f, frame_time_sq * 25.0f); + hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; + hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; } else { - if ((struct MobyView *)hero.unkA54 != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &((struct MobyView *)hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = D_0015ED6C_c * 4.5f; - } - FUN_L00_00212088(frame_time_sq * 25.0f, frame_time_sq * 25.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - FUN_L00_00212088(frame_time_sq * 15.0f, frame_time_sq * 15.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + FUN_L00_00212088(frame_time_sq * 15.0f, frame_time_sq * 15.0f); + FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); } if (hero.unkA58 != 0 || (struct MobyView *)hero.unkA54 != NULL) { hero.motion.move_yaw = hero.unkA5C; @@ -1606,35 +1583,17 @@ void FUN_L06_0022e020(void) { } FUN_L00_00217658(); } - if (0) { - if (FUN_L00_00211870(84.0f) != 0) { - f32 a = fast_add_rotations(hero.motion.rot.f[2], 3.1415927f); - f32 s = D_0015ED6C_c * 2.5f; - if (pad_held[0] & 0xA) { - s = D_0015ED6C_c * 3.0f; - } - hero.motion.velocity.f[0] += fast_cos(a) * s; - hero.motion.velocity.f[1] += fast_sin(a) * s; - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + FUN_L00_00212088(frame_time_sq * 37.0f, frame_time_sq * 28.0f); + set_planar_vel(99999.0f); + if (hero.air_frames.s != 0) { + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); } else { - FUN_L00_00212088(frame_time_sq * 37.0f, frame_time_sq * 28.0f); - set_planar_vel(99999.0f); - if (hero.air_frames.s != 0) { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); - } else { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); - } + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); } break; } case 0x13: { struct HeroTableRow2C *tb; - if (0) { - FUN_L00_002167d0(); - break; - } if (hero.unkA9C != 0 || hero.anim_frame < D_L06_0017C3A8[hero.attack_record].f20) { hero.items[0].timer = 2; } @@ -1761,22 +1720,13 @@ void FUN_L06_0022e020(void) { FUN_L00_00262528(&hero.trail.pos[0], 0xC, 6); } FUN_L00_00262608(&hero.trail.pos[0], t2 < hero.state_timer ? 5 : 0); - if (0) { - if (t1 < hero.state_timer && hero.state_timer < t1 + scale_game_frames(7) && hero.motion.unk168 < D_0015ED6C_c * 8.5f) { - hero.motion.velocity.f[0] += fast_cos(hero.motion.rot.f[2]) * (D_0015ED6C_c * 1.2f); - hero.motion.velocity.f[1] += fast_sin(hero.motion.rot.f[2]) * (D_0015ED6C_c * 1.2f); - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + if (t1 < hero.state_timer) { + FUN_L00_00212088(frame_time_sq * 190.0f, frame_time_sq * 90.0f); + } + if (hero.unkA58 != 0) { + set_planar_vel(hero.unkA5C); } else { - if (t1 < hero.state_timer) { - FUN_L00_00212088(frame_time_sq * 190.0f, frame_time_sq * 90.0f); - } - if (hero.unkA58 != 0) { - set_planar_vel(hero.unkA5C); - } else { - set_planar_vel(99999.0f); - } + set_planar_vel(99999.0f); } if (hero.state.current == 0x20 && t1 < hero.state_timer && hero.state_timer < t2 + scale_game_frames(4)) { struct MobyView *o = (struct MobyView *)hero.items[0].moby; @@ -2367,12 +2317,6 @@ void FUN_L06_0022e020(void) { if (hero.unk229C < 0.2f) { g = frame_time_sq * 3.5f; } - if (0) { - g = frame_time_sq * 3.7f; - if (hero.unk229C < 0.2f) { - g = frame_time_sq * 1.2f; - } - } FUN_L01_00234358(g); } FUN_L00_00215340(); diff --git a/src/overlays/l08/gameplay/hero/0021d9c0.c b/src/overlays/l08/gameplay/hero/0021d9c0.c index de4e4e67ec..6022eb2ac0 100644 --- a/src/overlays/l08/gameplay/hero/0021d9c0.c +++ b/src/overlays/l08/gameplay/hero/0021d9c0.c @@ -447,11 +447,7 @@ void FUN_L08_002284e0(void) { if (hero.unk20A9 != 0) { FUN_L00_00209540(0xF, 0x1E); } - if (0) { - FUN_L00_002132b8(0.7f, frame_time * 0.0f); - } else { - FUN_L00_002132b8(0.5f, frame_time * 2.0f); - } + FUN_L00_002132b8(0.5f, frame_time * 2.0f); FUN_L00_00217118(3.7f, 0.0f); stick_target(1.0f, 0); if (hero.state.current == HERO_STATE_LOOK || hero.state.current == 0x1E) { @@ -533,11 +529,7 @@ void FUN_L08_002284e0(void) { } } } else if (hero.state.current == HERO_STATE_CROUCH) { - if (0) { - speed = frame_time_sq * 1.7f; - } else { - speed = frame_time_sq * 6.48f; - } + speed = frame_time_sq * 6.48f; } else { speed = frame_time_sq * 12.6f; } @@ -1260,32 +1252,17 @@ void FUN_L08_002284e0(void) { hero.items[0].timer = 2; } hero.target_speed = 0.0f; - if (0) { - if (MV(hero.unkA54) != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &MV(hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = frame_time * 4.5f; - } - speed_step(frame_time_sq * 4.0f, frame_time_sq * 4.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - speed_step(frame_time_sq * 2.0f, frame_time_sq * 2.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + if (MV(hero.unkA54) != NULL) { + f32 d = FUN_001f9b80(&hero.motion.pos, &MV(hero.unkA54)->u10.v10); + if (d > 2.0f && d < 5.0f) { + hero.target_speed = frame_time * 4.5f; + } + speed_step(frame_time_sq * 25.0f, frame_time_sq * 25.0f); + hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; + hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; } else { - if (MV(hero.unkA54) != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &MV(hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = frame_time * 4.5f; - } - speed_step(frame_time_sq * 25.0f, frame_time_sq * 25.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - speed_step(frame_time_sq * 15.0f, frame_time_sq * 15.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + speed_step(frame_time_sq * 15.0f, frame_time_sq * 15.0f); + FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); } if (hero.unkA58 != 0 || MV(hero.unkA54) != NULL) { hero.motion.move_yaw = hero.unkA5C; @@ -1379,35 +1356,17 @@ void FUN_L08_002284e0(void) { } FUN_L00_00217658(); } - if (0) { - if (FUN_L00_00211870(84.0f) != 0) { - f32 a = fast_add_rotations(hero.motion.rot.f[2], 3.1415927f); - f32 s = frame_time * 2.5f; - if (pad_held[0] & 0xA) { - s = frame_time * 3.0f; - } - hero.motion.velocity.f[0] += fast_cos(a) * s; - hero.motion.velocity.f[1] += fast_sin(a) * s; - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + speed_step(frame_time_sq * 37.0f, frame_time_sq * 28.0f); + set_planar_vel(99999.0f); + if (hero.air_frames.s != 0) { + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); } else { - speed_step(frame_time_sq * 37.0f, frame_time_sq * 28.0f); - set_planar_vel(99999.0f); - if (hero.air_frames.s != 0) { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); - } else { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); - } + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); } break; } case 0x13: { struct HeroTableRow2C *tb; - if (0) { - FUN_L00_002167d0(); - break; - } if (hero.unkA9C != 0 || hero.anim_frame < D_L08_0017C428[hero.attack_record].f20) { hero.items[0].timer = 2; } @@ -1534,22 +1493,13 @@ void FUN_L08_002284e0(void) { FUN_L00_00262528(&hero.trail.pos[0], 0xC, 6); } FUN_L00_00262608(&hero.trail.pos[0], t2 < hero.state_timer ? 5 : 0); - if (0) { - if (t1 < hero.state_timer && hero.state_timer < t1 + scale_game_frames(7) && hero.motion.unk168 < frame_time * 8.5f) { - hero.motion.velocity.f[0] += fast_cos(hero.motion.rot.f[2]) * (frame_time * 1.2f); - hero.motion.velocity.f[1] += fast_sin(hero.motion.rot.f[2]) * (frame_time * 1.2f); - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + if (t1 < hero.state_timer) { + speed_step(frame_time_sq * 190.0f, frame_time_sq * 90.0f); + } + if (hero.unkA58 != 0) { + set_planar_vel(hero.unkA5C); } else { - if (t1 < hero.state_timer) { - speed_step(frame_time_sq * 190.0f, frame_time_sq * 90.0f); - } - if (hero.unkA58 != 0) { - set_planar_vel(hero.unkA5C); - } else { - set_planar_vel(99999.0f); - } + set_planar_vel(99999.0f); } if (hero.state.current == 0x20 && t1 < hero.state_timer && hero.state_timer < t2 + scale_game_frames(4)) { struct MobyView *o = MV(hero.items[0].moby); @@ -1780,6 +1730,7 @@ void FUN_L08_002284e0(void) { if (hero.motion.velocity.f[2] > frame_time_sq * -40.0f) { hero.motion.velocity.f[2] = frame_time_sq * -40.0f; } + /* Fakematch: cc1 drops the self-store, but it puts frame_time in $f2 as in retail. */ hero.target_speed = hero.target_speed; if (d > frame_time * 1.3962634f) { d = frame_time * 1.3962634f; @@ -2237,12 +2188,6 @@ void FUN_L08_002284e0(void) { if (hero.unk229C < 0.2f) { g = frame_time_sq * 3.5f; } - if (0) { - g = frame_time_sq * 3.7f; - if (hero.unk229C < 0.2f) { - g = frame_time_sq * 1.2f; - } - } air_accel(g); } FUN_L00_00215340(); diff --git a/src/overlays/l11/gameplay/hero/0023c7a0.c b/src/overlays/l11/gameplay/hero/0023c7a0.c index 360aa585b5..62ad2cb731 100644 --- a/src/overlays/l11/gameplay/hero/0023c7a0.c +++ b/src/overlays/l11/gameplay/hero/0023c7a0.c @@ -430,11 +430,7 @@ void FUN_L11_00246b70(void) { if (hero.unk20A9 != 0) { FUN_L00_00209540(0xF, 0x1E); } - if (0) { - FUN_L00_002132b8(0.7f, frame_time * 0.0f); - } else { - FUN_L00_002132b8(0.5f, frame_time * 2.0f); - } + FUN_L00_002132b8(0.5f, frame_time * 2.0f); FUN_L00_00217118(3.7f, 0.0f); stick_target(1.0f, 0); if (hero.state.current == HERO_STATE_LOOK || hero.state.current == 0x1E) { @@ -516,11 +512,7 @@ void FUN_L11_00246b70(void) { } } } else if (hero.state.current == HERO_STATE_CROUCH) { - if (0) { - speed = frame_time_sq * 1.7f; - } else { - speed = frame_time_sq * 6.48f; - } + speed = frame_time_sq * 6.48f; } else { speed = frame_time_sq * 12.6f; } @@ -1263,32 +1255,17 @@ void FUN_L11_00246b70(void) { hero.items[0].timer = 2; } hero.target_speed = 0.0f; - if (0) { - if (MV(hero.unkA54) != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &MV(hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = frame_time * 4.5f; - } - speed_step(frame_time_sq * 4.0f, frame_time_sq * 4.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - speed_step(frame_time_sq * 2.0f, frame_time_sq * 2.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + if (MV(hero.unkA54) != NULL) { + f32 d = FUN_001f9b80(&hero.motion.pos, &MV(hero.unkA54)->u10.v10); + if (d > 2.0f && d < 5.0f) { + hero.target_speed = frame_time * 4.5f; + } + speed_step(frame_time_sq * 25.0f, frame_time_sq * 25.0f); + hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; + hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; } else { - if (MV(hero.unkA54) != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &MV(hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = frame_time * 4.5f; - } - speed_step(frame_time_sq * 25.0f, frame_time_sq * 25.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - speed_step(frame_time_sq * 15.0f, frame_time_sq * 15.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + speed_step(frame_time_sq * 15.0f, frame_time_sq * 15.0f); + FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); } if (hero.unkA58 != 0 || MV(hero.unkA54) != NULL) { hero.motion.move_yaw = hero.unkA5C; @@ -1382,35 +1359,17 @@ void FUN_L11_00246b70(void) { } FUN_L00_00217658(); } - if (0) { - if (FUN_L00_00211870(84.0f) != 0) { - f32 a = fast_add_rotations(hero.motion.rot.f[2], 3.1415927f); - f32 s = frame_time * 2.5f; - if (pad_held[0] & 0xA) { - s = frame_time * 3.0f; - } - hero.motion.velocity.f[0] += fast_cos(a) * s; - hero.motion.velocity.f[1] += fast_sin(a) * s; - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + speed_step(frame_time_sq * 37.0f, frame_time_sq * 28.0f); + set_planar_vel(99999.0f); + if (hero.air_frames.s != 0) { + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); } else { - speed_step(frame_time_sq * 37.0f, frame_time_sq * 28.0f); - set_planar_vel(99999.0f); - if (hero.air_frames.s != 0) { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); - } else { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); - } + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); } break; } case 0x13: { struct HeroTableRow2C *tb; - if (0) { - FUN_L00_002167d0(); - break; - } if (hero.unkA9C != 0 || hero.anim_frame < D_L11_0017C628[hero.attack_record].f20) { hero.items[0].timer = 2; } @@ -1537,22 +1496,13 @@ void FUN_L11_00246b70(void) { FUN_L00_00262528(&hero.trail.pos[0], 0xC, 6); } FUN_L00_00262608(&hero.trail.pos[0], t2 < hero.state_timer ? 5 : 0); - if (0) { - if (t1 < hero.state_timer && hero.state_timer < t1 + scale_game_frames(7) && hero.motion.unk168 < frame_time * 8.5f) { - hero.motion.velocity.f[0] += fast_cos(hero.motion.rot.f[2]) * (frame_time * 1.2f); - hero.motion.velocity.f[1] += fast_sin(hero.motion.rot.f[2]) * (frame_time * 1.2f); - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + if (t1 < hero.state_timer) { + speed_step(frame_time_sq * 190.0f, frame_time_sq * 90.0f); + } + if (hero.unkA58 != 0) { + set_planar_vel(hero.unkA5C); } else { - if (t1 < hero.state_timer) { - speed_step(frame_time_sq * 190.0f, frame_time_sq * 90.0f); - } - if (hero.unkA58 != 0) { - set_planar_vel(hero.unkA5C); - } else { - set_planar_vel(99999.0f); - } + set_planar_vel(99999.0f); } if (hero.state.current == 0x20 && t1 < hero.state_timer && hero.state_timer < t2 + scale_game_frames(4)) { struct MobyView *o = MV(hero.items[0].moby); @@ -1843,12 +1793,6 @@ void FUN_L11_00246b70(void) { if (hero.unk229C < 0.2f) { g = frame_time_sq * 3.5f; } - if (0) { - g = frame_time_sq * 3.7f; - if (hero.unk229C < 0.2f) { - g = frame_time_sq * 1.2f; - } - } air_accel(g); } FUN_L00_00215340(); diff --git a/src/overlays/l14/gameplay/entities/jet.c b/src/overlays/l14/gameplay/entities/jet.c index 0a48fca4ac..6468b67b1f 100644 --- a/src/overlays/l14/gameplay/entities/jet.c +++ b/src/overlays/l14/gameplay/entities/jet.c @@ -107,6 +107,8 @@ void FUN_L14_002df138(u8 *moby) { wp = &d[20]; sixteen = 1.6f; one = 1.0f; + /* Fakematch: the extra loop level rematerialises the 4 and ranks the read + pointer above the counter in register allocation, as in retail. */ do { for (; k < 10; k++) { wp[2] = *rp; diff --git a/src/overlays/l14/gameplay/entities/morphoray.c b/src/overlays/l14/gameplay/entities/morphoray.c index a670466a31..93a62a117d 100644 --- a/src/overlays/l14/gameplay/entities/morphoray.c +++ b/src/overlays/l14/gameplay/entities/morphoray.c @@ -1331,6 +1331,8 @@ void FUN_L14_00314f00(char *a) { st->seg[k] = -1; } } + /* Fakematch: the dead update rotates the three address temps around + the atan2 call into retail's v0/a0/a1. */ D_L14_001600EC++; D_L14_001600EC--; st->fov_end = atan2_4f00(1.0f, D_L14_0016D140.fB0) * 2.0f; diff --git a/src/overlays/l15/gameplay/hero/002044c8.c b/src/overlays/l15/gameplay/hero/002044c8.c index d5d182110c..a60d3254fe 100644 --- a/src/overlays/l15/gameplay/hero/002044c8.c +++ b/src/overlays/l15/gameplay/hero/002044c8.c @@ -643,11 +643,7 @@ void FUN_L15_0020ed50(void) { if (hero.unk20A9 != 0) { FUN_L00_00209540(0xF, 0x1E); } - if (0) { - FUN_L00_002132b8(0.7f, frame_time * 0.0f); - } else { - FUN_L00_002132b8(0.5f, frame_time * 2.0f); - } + FUN_L00_002132b8(0.5f, frame_time * 2.0f); FUN_L00_00217118(3.7f, 0.0f); stick_target(1.0f, 0); if (hero.state.current == HERO_STATE_LOOK || hero.state.current == 0x1E) { @@ -729,11 +725,7 @@ void FUN_L15_0020ed50(void) { } } } else if (hero.state.current == HERO_STATE_CROUCH) { - if (0) { - speed = frame_time_sq * 1.7f; - } else { - speed = frame_time_sq * 6.48f; - } + speed = frame_time_sq * 6.48f; } else { speed = frame_time_sq * 12.6f; } @@ -1417,32 +1409,17 @@ void FUN_L15_0020ed50(void) { hero.items[0].timer = 2; } hero.target_speed = 0.0f; - if (0) { - if ((struct MobyView *)hero.unkA54 != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &((struct MobyView *)hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = frame_time * 4.5f; - } - speed_step(frame_time_sq * 4.0f, frame_time_sq * 4.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - speed_step(frame_time_sq * 2.0f, frame_time_sq * 2.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + if ((struct MobyView *)hero.unkA54 != NULL) { + f32 d = FUN_001f9b80(&hero.motion.pos, &((struct MobyView *)hero.unkA54)->u10.v10); + if (d > 2.0f && d < 5.0f) { + hero.target_speed = frame_time * 4.5f; + } + speed_step(frame_time_sq * 25.0f, frame_time_sq * 25.0f); + hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; + hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; } else { - if ((struct MobyView *)hero.unkA54 != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &((struct MobyView *)hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = frame_time * 4.5f; - } - speed_step(frame_time_sq * 25.0f, frame_time_sq * 25.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - speed_step(frame_time_sq * 15.0f, frame_time_sq * 15.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + speed_step(frame_time_sq * 15.0f, frame_time_sq * 15.0f); + FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); } if (hero.unkA58 != 0 || (struct MobyView *)hero.unkA54 != NULL) { hero.motion.move_yaw = hero.unkA5C; @@ -1536,35 +1513,17 @@ void FUN_L15_0020ed50(void) { } FUN_L00_00217658(); } - if (0) { - if (FUN_L00_00211870(84.0f) != 0) { - f32 a = fast_add_rotations(hero.motion.rot.f[2], 3.1415927f); - f32 s = frame_time * 2.5f; - if (pad_held[0] & 0xA) { - s = frame_time * 3.0f; - } - hero.motion.velocity.f[0] += fast_cos(a) * s; - hero.motion.velocity.f[1] += fast_sin(a) * s; - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + speed_step(frame_time_sq * 37.0f, frame_time_sq * 28.0f); + set_planar_vel(99999.0f); + if (hero.air_frames.s != 0) { + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); } else { - speed_step(frame_time_sq * 37.0f, frame_time_sq * 28.0f); - set_planar_vel(99999.0f); - if (hero.air_frames.s != 0) { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); - } else { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); - } + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); } break; } case 0x13: { struct HeroTableRow2C *tb; - if (0) { - FUN_L00_002167d0(); - break; - } if (hero.unkA9C != 0 || hero.anim_frame < D_L15_0017C228[hero.attack_record].f20) { hero.items[0].timer = 2; } @@ -1691,22 +1650,13 @@ void FUN_L15_0020ed50(void) { FUN_L00_00262528(&hero.trail.pos[0], 0xC, 6); } FUN_L00_00262608(&hero.trail.pos[0], t2 < hero.state_timer ? 5 : 0); - if (0) { - if (t1 < hero.state_timer && hero.state_timer < t1 + scale_game_frames(7) && hero.motion.unk168 < frame_time * 8.5f) { - hero.motion.velocity.f[0] += fast_cos(hero.motion.rot.f[2]) * (frame_time * 1.2f); - hero.motion.velocity.f[1] += fast_sin(hero.motion.rot.f[2]) * (frame_time * 1.2f); - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + if (t1 < hero.state_timer) { + speed_step(frame_time_sq * 190.0f, frame_time_sq * 90.0f); + } + if (hero.unkA58 != 0) { + set_planar_vel(hero.unkA5C); } else { - if (t1 < hero.state_timer) { - speed_step(frame_time_sq * 190.0f, frame_time_sq * 90.0f); - } - if (hero.unkA58 != 0) { - set_planar_vel(hero.unkA5C); - } else { - set_planar_vel(99999.0f); - } + set_planar_vel(99999.0f); } if (hero.state.current == 0x20 && t1 < hero.state_timer && hero.state_timer < t2 + scale_game_frames(4)) { struct MobyView *o = (struct MobyView *)hero.items[0].moby; @@ -1897,6 +1847,7 @@ void FUN_L15_0020ed50(void) { if (hero.motion.velocity.f[2] > frame_time_sq * -40.0f) { hero.motion.velocity.f[2] = frame_time_sq * -40.0f; } + /* Fakematch: cc1 drops the self-store, but it puts frame_time in $f2 as in retail. */ hero.target_speed = hero.target_speed; if (d > frame_time * 1.3962634f) { d = frame_time * 1.3962634f; @@ -2049,12 +2000,6 @@ void FUN_L15_0020ed50(void) { if (hero.unk229C < 0.2f) { g = frame_time_sq * 3.5f; } - if (0) { - g = frame_time_sq * 3.7f; - if (hero.unk229C < 0.2f) { - g = frame_time_sq * 1.2f; - } - } air_accel(g); } FUN_L00_00215340(); diff --git a/src/overlays/l16/gameplay/hero/00214598.c b/src/overlays/l16/gameplay/hero/00214598.c index d901d4e750..11508b1ff8 100644 --- a/src/overlays/l16/gameplay/hero/00214598.c +++ b/src/overlays/l16/gameplay/hero/00214598.c @@ -346,11 +346,7 @@ void FUN_L16_00214598(void) { if (hero.unk20A9 != 0) { FUN_L00_00209540(0xF, 0x1E); } - if (0) { - FUN_L00_002132b8(0.7f, frame_time * 0.0f); - } else { - FUN_L00_002132b8(0.5f, frame_time * 2.0f); - } + FUN_L00_002132b8(0.5f, frame_time * 2.0f); FUN_L00_00217118(3.7f, 0.0f); stick_target(1.0f, 0); if (hero.state.current == HERO_STATE_LOOK || hero.state.current == 0x1E) { @@ -432,11 +428,7 @@ void FUN_L16_00214598(void) { } } } else if (hero.state.current == HERO_STATE_CROUCH) { - if (0) { - speed = frame_time_sq * 1.7f; - } else { - speed = frame_time_sq * 6.48f; - } + speed = frame_time_sq * 6.48f; } else { speed = frame_time_sq * 12.6f; } @@ -1567,32 +1559,17 @@ void FUN_L16_00214598(void) { hero.items[0].timer = 2; } hero.target_speed = 0.0f; - if (0) { - if ((struct MobyView *)hero.unkA54 != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &((struct MobyView *)hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = frame_time * 4.5f; - } - speed_step(frame_time_sq * 4.0f, frame_time_sq * 4.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - speed_step(frame_time_sq * 2.0f, frame_time_sq * 2.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + if ((struct MobyView *)hero.unkA54 != NULL) { + f32 d = FUN_001f9b80(&hero.motion.pos, &((struct MobyView *)hero.unkA54)->u10.v10); + if (d > 2.0f && d < 5.0f) { + hero.target_speed = frame_time * 4.5f; + } + speed_step(frame_time_sq * 25.0f, frame_time_sq * 25.0f); + hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; + hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; } else { - if ((struct MobyView *)hero.unkA54 != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &((struct MobyView *)hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = frame_time * 4.5f; - } - speed_step(frame_time_sq * 25.0f, frame_time_sq * 25.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - speed_step(frame_time_sq * 15.0f, frame_time_sq * 15.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + speed_step(frame_time_sq * 15.0f, frame_time_sq * 15.0f); + FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); } if (hero.unkA58 != 0 || (struct MobyView *)hero.unkA54 != NULL) { hero.motion.move_yaw = hero.unkA5C; @@ -1686,35 +1663,17 @@ void FUN_L16_00214598(void) { } FUN_L00_00217658(); } - if (0) { - if (FUN_L00_00211870(84.0f) != 0) { - f32 a = fast_add_rotations(hero.motion.rot.f[2], 3.1415927f); - f32 s = frame_time * 2.5f; - if (pad_held[0] & 0xA) { - s = frame_time * 3.0f; - } - hero.motion.velocity.f[0] += fast_cos(a) * s; - hero.motion.velocity.f[1] += fast_sin(a) * s; - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + speed_step(frame_time_sq * 37.0f, frame_time_sq * 28.0f); + set_planar_vel(99999.0f); + if (hero.air_frames.s != 0) { + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); } else { - speed_step(frame_time_sq * 37.0f, frame_time_sq * 28.0f); - set_planar_vel(99999.0f); - if (hero.air_frames.s != 0) { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); - } else { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); - } + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); } break; } case 0x13: { struct HeroTableRow2C *tb; - if (0) { - FUN_L00_002167d0(); - break; - } if (hero.unkA9C != 0 || hero.anim_frame < D_L16_0017C088[hero.attack_record].f20) { hero.items[0].timer = 2; } @@ -1841,22 +1800,13 @@ void FUN_L16_00214598(void) { FUN_L00_00262528(&hero.trail.pos[0], 0xC, 6); } FUN_L00_00262608(&hero.trail.pos[0], t2 < hero.state_timer ? 5 : 0); - if (0) { - if (t1 < hero.state_timer && hero.state_timer < t1 + scale_game_frames(7) && hero.motion.unk168 < frame_time * 8.5f) { - hero.motion.velocity.f[0] += fast_cos(hero.motion.rot.f[2]) * (frame_time * 1.2f); - hero.motion.velocity.f[1] += fast_sin(hero.motion.rot.f[2]) * (frame_time * 1.2f); - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + if (t1 < hero.state_timer) { + speed_step(frame_time_sq * 190.0f, frame_time_sq * 90.0f); + } + if (hero.unkA58 != 0) { + set_planar_vel(hero.unkA5C); } else { - if (t1 < hero.state_timer) { - speed_step(frame_time_sq * 190.0f, frame_time_sq * 90.0f); - } - if (hero.unkA58 != 0) { - set_planar_vel(hero.unkA5C); - } else { - set_planar_vel(99999.0f); - } + set_planar_vel(99999.0f); } if (hero.state.current == 0x20 && t1 < hero.state_timer && hero.state_timer < t2 + scale_game_frames(4)) { struct MobyView *o = (struct MobyView *)hero.items[0].moby; @@ -2087,6 +2037,7 @@ void FUN_L16_00214598(void) { if (hero.motion.velocity.f[2] > frame_time_sq * -40.0f) { hero.motion.velocity.f[2] = frame_time_sq * -40.0f; } + /* Fakematch: cc1 drops the self-store, but it puts frame_time in $f2 as in retail. */ hero.target_speed = hero.target_speed; if (d > frame_time * 1.3962634f) { d = frame_time * 1.3962634f; @@ -2544,12 +2495,6 @@ void FUN_L16_00214598(void) { if (hero.unk229C < 0.2f) { g = frame_time_sq * 3.5f; } - if (0) { - g = frame_time_sq * 3.7f; - if (hero.unk229C < 0.2f) { - g = frame_time_sq * 1.2f; - } - } air_accel(g); } FUN_L00_00215340(); diff --git a/src/overlays/l17/gameplay/hero/00214760.c b/src/overlays/l17/gameplay/hero/00214760.c index c204570e3e..8553677b07 100644 --- a/src/overlays/l17/gameplay/hero/00214760.c +++ b/src/overlays/l17/gameplay/hero/00214760.c @@ -1731,6 +1731,7 @@ void FUN_L17_00214760(void) { if (hero.motion.velocity.f[2] > frame_time_sq * -40.0f) { hero.motion.velocity.f[2] = frame_time_sq * -40.0f; } + /* Fakematch: cc1 drops the self-store, but it puts frame_time in $f2 as in retail. */ hero.target_speed = hero.target_speed; if (d > frame_time * 1.3962634f) { d = frame_time * 1.3962634f; diff --git a/src/overlays/l18/gameplay/hero/0021eac8.c b/src/overlays/l18/gameplay/hero/0021eac8.c index 9afc03b575..b6f6bd2479 100644 --- a/src/overlays/l18/gameplay/hero/0021eac8.c +++ b/src/overlays/l18/gameplay/hero/0021eac8.c @@ -329,11 +329,7 @@ void FUN_L18_0021eac8(void) { if (hero.unk20A9 != 0) { FUN_L00_00209540(0xF, 0x1E); } - if (0) { - FUN_L00_002132b8(0.7f, frame_time * 0.0f); - } else { - FUN_L00_002132b8(0.5f, frame_time * 2.0f); - } + FUN_L00_002132b8(0.5f, frame_time * 2.0f); FUN_L00_00217118(3.7f, 0.0f); stick_target(1.0f, 0); if (hero.state.current == HERO_STATE_LOOK || hero.state.current == 0x1E) { @@ -415,11 +411,7 @@ void FUN_L18_0021eac8(void) { } } } else if (hero.state.current == HERO_STATE_CROUCH) { - if (0) { - speed = frame_time_sq * 1.7f; - } else { - speed = frame_time_sq * 6.48f; - } + speed = frame_time_sq * 6.48f; } else { speed = frame_time_sq * 12.6f; } @@ -1123,32 +1115,17 @@ void FUN_L18_0021eac8(void) { hero.items[0].timer = 2; } hero.target_speed = 0.0f; - if (0) { - if ((struct MobyView *)hero.unkA54 != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &((struct MobyView *)hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = frame_time * 4.5f; - } - speed_step(frame_time_sq * 4.0f, frame_time_sq * 4.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - speed_step(frame_time_sq * 2.0f, frame_time_sq * 2.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + if ((struct MobyView *)hero.unkA54 != NULL) { + f32 d = FUN_001f9b80(&hero.motion.pos, &((struct MobyView *)hero.unkA54)->u10.v10); + if (d > 2.0f && d < 5.0f) { + hero.target_speed = frame_time * 4.5f; + } + speed_step(frame_time_sq * 25.0f, frame_time_sq * 25.0f); + hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; + hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; } else { - if ((struct MobyView *)hero.unkA54 != NULL) { - f32 d = FUN_001f9b80(&hero.motion.pos, &((struct MobyView *)hero.unkA54)->u10.v10); - if (d > 2.0f && d < 5.0f) { - hero.target_speed = frame_time * 4.5f; - } - speed_step(frame_time_sq * 25.0f, frame_time_sq * 25.0f); - hero.motion.velocity.f[0] = fast_cos(hero.motion.rot.f[2]) * hero.ground_speed; - hero.motion.velocity.f[1] = fast_sin(hero.motion.rot.f[2]) * hero.ground_speed; - } else { - speed_step(frame_time_sq * 15.0f, frame_time_sq * 15.0f); - FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); - } + speed_step(frame_time_sq * 15.0f, frame_time_sq * 15.0f); + FUN_L00_00233ba0(&hero.motion.velocity, &hero.motion.velocity, hero.ground_speed); } if (hero.unkA58 != 0 || (struct MobyView *)hero.unkA54 != NULL) { hero.motion.move_yaw = hero.unkA5C; @@ -1242,35 +1219,17 @@ void FUN_L18_0021eac8(void) { } FUN_L00_00217658(); } - if (0) { - if (FUN_L00_00211870(84.0f) != 0) { - f32 a = fast_add_rotations(hero.motion.rot.f[2], 3.1415927f); - f32 s = frame_time * 2.5f; - if (pad_held[0] & 0xA) { - s = frame_time * 3.0f; - } - hero.motion.velocity.f[0] += fast_cos(a) * s; - hero.motion.velocity.f[1] += fast_sin(a) * s; - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + speed_step(frame_time_sq * 37.0f, frame_time_sq * 28.0f); + set_planar_vel(99999.0f); + if (hero.air_frames.s != 0) { + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); } else { - speed_step(frame_time_sq * 37.0f, frame_time_sq * 28.0f); - set_planar_vel(99999.0f); - if (hero.air_frames.s != 0) { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.unk120, frame_time_sq * 25.0f); - } else { - FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); - } + FUN_L00_002334d0(&hero.motion.velocity, &hero.motion.velocity, frame_time_sq * 54.0f); } break; } case 0x13: { struct HeroTableRow2C *tb; - if (0) { - FUN_L00_002167d0(); - break; - } if (hero.unkA9C != 0 || hero.anim_frame < D_L18_0017C628[hero.attack_record].f20) { hero.items[0].timer = 2; } @@ -1397,22 +1356,13 @@ void FUN_L18_0021eac8(void) { FUN_L00_00262528(&hero.trail.pos[0], 0xC, 6); } FUN_L00_00262608(&hero.trail.pos[0], t2 < hero.state_timer ? 5 : 0); - if (0) { - if (t1 < hero.state_timer && hero.state_timer < t1 + scale_game_frames(7) && hero.motion.unk168 < frame_time * 8.5f) { - hero.motion.velocity.f[0] += fast_cos(hero.motion.rot.f[2]) * (frame_time * 1.2f); - hero.motion.velocity.f[1] += fast_sin(hero.motion.rot.f[2]) * (frame_time * 1.2f); - qcopy(&hero.motion.unk130, &hero.motion.velocity); - } - FUN_L00_002167d0(); + if (t1 < hero.state_timer) { + speed_step(frame_time_sq * 190.0f, frame_time_sq * 90.0f); + } + if (hero.unkA58 != 0) { + set_planar_vel(hero.unkA5C); } else { - if (t1 < hero.state_timer) { - speed_step(frame_time_sq * 190.0f, frame_time_sq * 90.0f); - } - if (hero.unkA58 != 0) { - set_planar_vel(hero.unkA5C); - } else { - set_planar_vel(99999.0f); - } + set_planar_vel(99999.0f); } if (hero.state.current == 0x20 && t1 < hero.state_timer && hero.state_timer < t2 + scale_game_frames(4)) { struct MobyView *o = (struct MobyView *)hero.items[0].moby; @@ -1643,6 +1593,7 @@ void FUN_L18_0021eac8(void) { if (hero.motion.velocity.f[2] > frame_time_sq * -40.0f) { hero.motion.velocity.f[2] = frame_time_sq * -40.0f; } + /* Fakematch: cc1 drops the self-store, but it puts frame_time in $f2 as in retail. */ hero.target_speed = hero.target_speed; if (d > frame_time * 1.3962634f) { d = frame_time * 1.3962634f; @@ -2100,12 +2051,6 @@ void FUN_L18_0021eac8(void) { if (hero.unk229C < 0.2f) { g = frame_time_sq * 3.5f; } - if (0) { - g = frame_time_sq * 3.7f; - if (hero.unk229C < 0.2f) { - g = frame_time_sq * 1.2f; - } - } air_accel(g); } FUN_L00_00215340(); diff --git a/src/overlays/shared/gameplay/hero/hero_idle_sequence.c b/src/overlays/shared/gameplay/hero/hero_idle_sequence.c index f233f72109..82a0ba9996 100644 --- a/src/overlays/shared/gameplay/hero/hero_idle_sequence.c +++ b/src/overlays/shared/gameplay/hero/hero_idle_sequence.c @@ -933,7 +933,7 @@ void FUN_L00_00206c08(void) { clear: *slot = -1; slot++; - /* empty block between the two steps: retail steps slot before off */ + /* Fakematch: the empty block makes retail step slot before off. */ do { } while (0); off += 4; diff --git a/src/overlays/shared/gameplay/hero/hero_update_movement.c b/src/overlays/shared/gameplay/hero/hero_update_movement.c index 4b8423ac58..cad9a26ff1 100644 --- a/src/overlays/shared/gameplay/hero/hero_update_movement.c +++ b/src/overlays/shared/gameplay/hero/hero_update_movement.c @@ -1733,6 +1733,7 @@ void hero_update_movement(void) { if (hero.motion.velocity.f[2] > frame_time_sq * -40.0f) { hero.motion.velocity.f[2] = frame_time_sq * -40.0f; } + /* Fakematch: cc1 drops the self-store, but it puts frame_time in $f2 as in retail. */ hero.target_speed = hero.target_speed; if (d > frame_time * 1.3962634f) { d = frame_time * 1.3962634f; diff --git a/src/overlays/shared/rendering/002712b8.c b/src/overlays/shared/rendering/002712b8.c index ba819598e9..7a3d91e503 100644 --- a/src/overlays/shared/rendering/002712b8.c +++ b/src/overlays/shared/rendering/002712b8.c @@ -550,6 +550,7 @@ s32 FUN_001fa6d0(f32); void add_vector_xyz_cf(u8 *, u8 *, void *) __asm__("FUN_L00_0024f7c8"); P_2725d8 *FUN_L00_002725d8(u8 *a0, u8 *a1, s32 a2, s32 a3, f32 a4, f32 a5) { P_2725d8 *p = FUN_L00_002678b8_c2(0x37); + /* Fakematch: the dead update gives a0 and a3 retail's saved registers. */ a3++; a3--; if (p) { diff --git a/src/rendering/state/reset_graphics.c b/src/rendering/state/reset_graphics.c index 9630d7d2d3..14f9b9a43a 100644 --- a/src/rendering/state/reset_graphics.c +++ b/src/rendering/state/reset_graphics.c @@ -30,6 +30,7 @@ void reset_graphics(void) { init_dma(); sceGsResetGraph(0, 1, (D_0015ED80[0] != 0) ? 3 : 2, 0); reset_vif1_gif(); + /* Fakematch: see the note at the top of the function. */ do { vu1_init_chain(); temp_16_31 = D_0015EE78[0]; diff --git a/src/runtime/newlib/double_is_not_nan.c b/src/runtime/newlib/double_is_not_nan.c index f4797e7171..a793c2814a 100644 --- a/src/runtime/newlib/double_is_not_nan.c +++ b/src/runtime/newlib/double_is_not_nan.c @@ -1,6 +1,5 @@ #include "types.h" -/* fdlibm word-access shape: EXTRACT_WORDS() is a do { ... } while (0) macro */ typedef union { f64 value; struct { @@ -9,18 +8,22 @@ typedef union { } parts; } ieee_double_shape_type; +/* fdlibm math_private.h */ +#define EXTRACT_WORDS(ix0, ix1, d) \ + do { \ + ieee_double_shape_type ew_u; \ + ew_u.value = (d); \ + (ix0) = ew_u.parts.msw; \ + (ix1) = ew_u.parts.lsw; \ + } while (0) + s32 double_is_not_nan(f64 x) __asm__("FUN_00116168"); s32 double_is_not_nan(f64 x) { s32 hx; s32 lx; - ieee_double_shape_type ew_u; - do { - ew_u.value = x; - hx = ew_u.parts.msw; - lx = ew_u.parts.lsw; - } while (0); + EXTRACT_WORDS(hx, lx, x); hx &= 0x7fffffff; hx |= (u32)(lx | (-lx)) >> 31; hx = 0x7ff00000 - hx; diff --git a/src/runtime/newlib/vfprintf.c b/src/runtime/newlib/vfprintf.c index dd651a0e77..afe06c5ef2 100644 --- a/src/runtime/newlib/vfprintf.c +++ b/src/runtime/newlib/vfprintf.c @@ -10,18 +10,21 @@ typedef struct { extern struct _reent *D_0012F76C[]; extern void __sinit(struct _reent *); extern s32 _vfprintf_r(struct _reent *, FILE *, const char *, void *); -/* newlib vfprintf: CHECK_INIT (fp) then _vfprintf_r. */ +/* newlib local.h */ +#define CHECK_INIT(fp) \ + do { \ + if ((fp)->_data == 0) { \ + (fp)->_data = D_0012F76C[0]; \ + } \ + if (!(fp)->_data->__sdidinit) { \ + __sinit((fp)->_data); \ + } \ + } while (0) + s32 vfprintf(FILE *fp, const char *fmt0, void *ap) __asm__("FUN_00116da8"); s32 vfprintf(FILE *fp, const char *fmt0, void *ap) { - do { - if (fp->_data == 0) { - fp->_data = D_0012F76C[0]; - } - if (!fp->_data->__sdidinit) { - __sinit(fp->_data); - } - } while (0); + CHECK_INIT(fp); return _vfprintf_r(fp->_data, fp, fmt0, ap); } diff --git a/src/runtime/startup/run_global_constructors.c b/src/runtime/startup/run_global_constructors.c index 6c33366407..930528fa65 100644 --- a/src/runtime/startup/run_global_constructors.c +++ b/src/runtime/startup/run_global_constructors.c @@ -1,22 +1,24 @@ #include "types.h" typedef void (*func_ptr)(void); extern func_ptr D_0015EC18[]; -/* libgcc __do_global_ctors: the body is gbl-ctors.h DO_GLOBAL_CTORS_BODY. */ +/* libgcc gbl-ctors.h */ +#define DO_GLOBAL_CTORS_BODY \ + do { \ + unsigned long nptrs = (unsigned long)D_0015EC18[0]; \ + unsigned i; \ + if (nptrs == (unsigned long)-1) { \ + for (nptrs = 0; D_0015EC18[nptrs + 1] != 0; nptrs++) { \ + } \ + } \ + for (i = nptrs; i >= 1; i--) { \ + D_0015EC18[i](); \ + } \ + } while (0) + void run_global_constructors(void) __asm__("FUN_0011dc18"); void run_global_constructors(void) { - do { - unsigned long nptrs = (unsigned long)D_0015EC18[0]; - unsigned i; - - if (nptrs == (unsigned long)-1) { - for (nptrs = 0; D_0015EC18[nptrs + 1] != 0; nptrs++) { - } - } - for (i = nptrs; i >= 1; i--) { - D_0015EC18[i](); - } - } while (0); + DO_GLOBAL_CTORS_BODY; } extern __typeof__(run_global_constructors) func_0011DC18 __attribute__((alias("FUN_0011dc18"))); diff --git a/src/textbin/rebuild_configured_text_label_list.c b/src/textbin/rebuild_configured_text_label_list.c index 7aa6f7eabf..38958436a3 100644 --- a/src/textbin/rebuild_configured_text_label_list.c +++ b/src/textbin/rebuild_configured_text_label_list.c @@ -45,6 +45,7 @@ s32 rebuild_configured_text_label_list(void) { text_ids = label_text_table; do { entry_count = 0; + /* Fakematch: the block swaps the selector and entry pointers into retail's registers. */ do { /* Retail scans twelve selectors despite copying eight selector words and seven text words. Preserve that original overrun while this stays pending. */ diff --git a/src/ui/menus/item_preview/load_preview_resource_bindings.c b/src/ui/menus/item_preview/load_preview_resource_bindings.c index 033d6fb2d5..3ae8a39133 100644 --- a/src/ui/menus/item_preview/load_preview_resource_bindings.c +++ b/src/ui/menus/item_preview/load_preview_resource_bindings.c @@ -44,9 +44,9 @@ void load_preview_resource_bindings(s32 first_resource, s32 resource_count) { buffer_skip = 0; class_slot = resident_class_slot_by_id[binding->class_id]; animation_index = binding->animation_index; - /* Two bindings use resource buffers 0 and 2. The do-while - weights the index use one loop deeper, so the index is - allocated before the binding pointer. */ + /* Fakematch: two bindings use resource buffers 0 and 2. The + do-while weights the index use one loop deeper, so the index + is allocated before the binding pointer. */ if (count == 2) { do { if (resource_index == 1) { diff --git a/src/ui/menus/setup_menu_display_text.c b/src/ui/menus/setup_menu_display_text.c index 86ebd8baf5..bdbcf5057c 100644 --- a/src/ui/menus/setup_menu_display_text.c +++ b/src/ui/menus/setup_menu_display_text.c @@ -8,7 +8,6 @@ extern void do_gif_paging(void) __asm__("func_001F4398"); extern void draw_moby_list(int, int) __asm__("func_0020D330"); extern void *func_001FE540_id(int) __asm__("func_001FDD10"); extern const float D_001602A4_f __asm__("D_001602A4") __attribute__((sda)); -extern short D_001602A4_s __asm__("D_001602A4"); extern char D_001602A8[]; extern int D_001E0888[]; #include "rnc/rendering/screen.h" @@ -43,9 +42,6 @@ int setup_menu_display_text(char *menu) { func_001F6CF8_c(*(int *)(menu + 0x20) - 0x10, (screen_extent.height >> 1) - 8, 0x80000000L, buf, -1); func_001F6CF8_c(*(int *)(menu + 0x20) - 0x11, (screen_extent.height >> 1) - 9, 0x80FFA888L, buf, -1); do_gif_paging(); - if (0) { - (void)D_001602A4_s; - } return 8; } diff --git a/src/video/decoder/video_dec_abort.c b/src/video/decoder/video_dec_abort.c index e0b40fc5bb..33f118cfc8 100644 --- a/src/video/decoder/video_dec_abort.c +++ b/src/video/decoder/video_dec_abort.c @@ -5,6 +5,7 @@ int video_dec_abort(int *state_fields) __asm__("func_0023CC70"); int video_dec_abort(int *state_fields) { int value = 1; + /* Fakematch: the block makes the store and the return share one register. */ do { state_fields[42] = value; } while (0);