Files
cecilarmitais 457a2aaf17 Decompile 8 more functions; clear four asm files entirely
Clears asm/main_02048B74.s, asm/overlay_29_022DC314.s,
asm/overlay_29_022E9628.s and asm/overlay_29_023456BC.s, with their .inc
headers and main.lsf entries.

New translation units, both created with extract_function.py -nm rather than
merged, to keep a small callee out of the same TU:

- src/overlay_29_022E9628.c (GetRandomTile, FindNearbyUnoccupiedTile). A
  backward merge would have landed these beside GetLeader in src/dg_uty.c,
  where -O4,s can inline it; and dg_uty.c declares DUNGEON_PTR as the
  INCOMPLETE array form, while these two were scored against the complete
  [2] form. The two spellings are not interchangeable (see MATCHING_TIPS,
  "DUNGEON_PTR: the lever is the COMPLETENESS of the declared type"), so the
  file keeps [2] and src/overlay_29_023456BC.c keeps [] deliberately.
- src/overlay_29_023456BC.c (RemoveGroundItem, DisplayItem). Same reason:
  src/overlay_29_02345698.c holds the three-instruction
  EntityIsValid__02345698, which both of these call.

Backward merges where that was safe:

- sub_02048B74 -> src/main_02048B48.c
- ov29_022DC314 / ov29_022DC33C / ov29_022DC544 -> src/poly_text.c, which
  already owns the buffer type ov29_022DC33C takes.

DECLARATION CHANGES, all measured byte-neutral rather than argued. Each file
below was compiled before and after with the real build flags (-W all
-W pedantic -W error) and produced a byte-identical object:

- src/main_02048BB4.c: _020AFF38 scalar -> incomplete array, and its five
  accesses. The array form is what sub_02048B74 matches under; the two TUs
  that declare the symbol now agree.
- src/overlay_29_022E99F0.c + include/overlay_29_022E99F0.h: the three
  FindNearby* wrappers retyped struct position* -> bool32, and the three
  DISPLACEMENTS_* externs const s32[] -> const struct position[]. The asm
  indexes them with lsl #2 and then reads two signed halfwords four bytes
  apart, which const s32* cannot produce, and the rodata decodes as {s16 x,
  s16 y} pairs. The return retype is safe because all four call sites already
  use the result as a boolean and none takes it as a pointer;
  FindFarthestUnoccupiedTileWithin2 has no C caller at all. bool32 rather
  than bool8 because the wrappers tail-return r0.
- src/overlay_29_022DC61C.c: five stale externs replaced by an include of
  poly_text.h, and ov29_023538B4 retyped from u8[0x1963C] to the real struct.
- src/dungeon_projectile_throw.c, src/main_020483B8.c,
  src/overlay_29_0230F810.c, src/overlay_29_02320764.c: stale externs
  replaced by includes.

include/poly_text.h carried three defects, all fixed. This header is already
landed and matching, and src/poly_text.c decompiles two sibling functions
against it, so the layout is backed by matching code:

- s16 unk17704[0xf92] ran 0x17704 -> 0x19628 and SWALLOWED the 350-element
  array at 0x18304. Split to [0x600], ending exactly at 0x18304, followed by
  struct unk_ov29_022DC240_18304_t unk18304[350]. The siblings corroborate
  independently: ov29_022DC240 sets unk8 = 0x40 and unka = 0x18, and
  ov29_022DC2B8 zeroes unk17704[i] for i < unk8 * unka = 0x600.
- s16 unk19628 -> u16; the target loads it with ldrh.
- `} unk1962a;` was a file-scope tentative definition inside a header, which
  MWCC emits as a DEFINED symbol, so a second includer collides. Deleting it
  is NOT object-neutral (1000 -> 928 bytes); it is MOVED into src/poly_text.c,
  which is object-neutral and was verified as such.

ov29_022DC33C reads an uninitialised local, and that is a property of the
ROM: the target does `ldrh r3, [sp]` before anything stores to that slot.
-W error rejects the direct spelling, and neither a one-member struct nor a
one-element array suppresses it. Reading and writing through a pointer local
satisfies the diagnostic and emits nothing; landcheck confirms 130/130 words
byte-identical.

include/overlay_29_022E99F0.h gains #include "dungeon_mode.h". The bug was
latent, not introduced: the header named struct position without defining it
and compiled only because its struct position* RETURN type introduced the tag
at file scope. Retyping the return to bool32 removed that, and every parameter
list then declared its own scoped type.

Authored by Claude (Opus 5) under human direction. Every function was
byte-compared against the assembly it replaced with build-tools/landcheck.sh
before any build, and every edit to an already-landed file was proved
byte-neutral by an object diff. Confirmed by matching builds in all three
regions: build/pmdsky.us/pmdsky.us.nds: OK, build/pmdsky.eu/pmdsky.eu.nds: OK,
build/pmdsky.jp/pmdsky.jp.nds: OK.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-18 23:14:59 -07:00
..
…
…
…
2026-08-22 20:45:50 -04:00
2026-09-16 22:13:55 -04:00
2026-09-16 19:13:16 -04:00
2026-08-01 12:46:55 -04:00
2026-08-22 20:45:50 -04:00
2026-09-06 23:42:12 -04:00
2026-08-12 12:04:11 -07:00
2026-08-12 12:04:11 -07:00
2026-09-06 23:42:12 -04:00
2026-08-22 20:45:50 -04:00
2026-08-22 20:45:50 -04:00
2026-09-06 23:42:12 -04:00
2026-08-22 20:45:50 -04:00
2026-09-06 23:42:12 -04:00
2026-09-06 23:42:12 -04:00
2026-09-06 23:42:12 -04:00
2026-09-06 23:42:12 -04:00
2026-07-31 18:03:24 -04:00
2026-09-06 23:42:12 -04:00
2026-07-31 18:03:24 -04:00
2026-07-31 18:03:24 -04:00
2026-09-06 23:42:12 -04:00
2026-09-06 23:42:12 -04:00
2026-09-06 23:42:12 -04:00
2026-07-31 18:03:24 -04:00
2026-07-31 18:03:24 -04:00
2026-09-06 23:42:12 -04:00
2026-09-06 23:42:12 -04:00
2026-07-31 18:03:24 -04:00
2026-09-06 23:42:12 -04:00
2026-09-16 22:13:55 -04:00
2026-09-06 23:42:12 -04:00
2026-08-22 20:45:50 -04:00
2026-07-31 18:03:24 -04:00
2026-09-06 23:42:12 -04:00
2026-09-06 23:42:12 -04:00
2026-09-06 23:42:12 -04:00
2026-08-22 20:45:50 -04:00
2026-09-06 23:42:12 -04:00
2026-08-22 20:45:50 -04:00
2026-09-06 23:42:12 -04:00
2026-09-04 12:45:57 -07:00
2026-09-06 23:42:12 -04:00
2026-08-01 12:46:55 -04:00