cecilarmitais f47593d94e Decomp sub_0203D538; replace its stale extern with the new header
sub_0203D538 (0x0203D538, 1666 instructions in US and EU, 1640 in JP) is the
mission-reward state machine: a 77-case dense switch over
MISSION_REWARD_STRUCT_MAIN_PTR->field_0x0 driving money, egg, item, rank-up
and recruit rewards through dialogue boxes and menus. It is function 13 of
89 in asm/main_0203CAF0.s, so extract_function.py splits rather than merges:
the 76 functions after it move to asm/main_0203EFD4.s, the function lands in
src/main_0203D538.c with include/main_0203D538.h, and main.lsf lists both new
objects where it listed one.

src/overlay_24_init.c declared sub_0203D538 itself, with a live call site in
a switch. That extern is removed and the file now includes the new header.

Case order is source order and is not ascending - two contiguous runs are
swapped (32,33,34 before 30,31; and 52..57 before 45..51), read off the jump
table. Every case ends `break` with a single `return 0` after the switch,
because the target's exit block itself materialises the value: a `return 0`
per case makes MWCC materialise r0 at each of 77 sites and, worse,
de-predicates the short blocks above them. case 76 keeps its `return 1`,
which is how the target jumps past that shared `mov r0, #0`.

The nine function-scope locals are declared buffer-first then the five
struct item in reverse case order, because MWCC gives the first-declared
local the highest stack address and the target wants the buffer at sp+0x22.
That ordering costs no instructions, so it shows up only as a wrong offset at
every stack access - not as a length difference.

struct unk_020AFE74 is a placeholder for the 0x3C0-byte state struct, with
field_0x<off> members and two u8 filler ranges this function never touches;
it cannot be honestly typed from one caller. The 19 callees with no
declaration anywhere are declared extern in the .c with prototypes read off
their own asm, and two of them - sub_02046C78 and sub_02046D20 - take no
arguments, contradicting src/main_020663C8.c.

Region handling: 35 message ids carry a uniform +0x21D4 under JAPAN via one
file-scope offset macro; one id at 0x2CC shifts by +0x2D20 instead and needs
its own ifdef; StrncpySimple becomes the two-argument StrcpySimple; and JAPAN
omits case 74's item fetch, its name formatting and its early-exit guard,
which is what removes a struct item local and takes the frame from 0x11C to
0x114. EUROPE is byte-identical to NORTH_AMERICA - there is no EUROPE
directive anywhere in this function.

Authored by Claude (Opus 5) under human direction. Confirmed by matching
builds of 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:12:41 -07:00
2026-04-08 09:53:43 +02:00
2024-04-17 23:52:39 -04:00
2026-08-22 20:45:50 -04:00
2023-11-20 17:24:08 -06:00
2024-06-23 16:59:48 -05:00
2023-08-13 23:03:51 -04:00
2024-12-28 02:25:07 -06:00
2026-08-01 12:46:55 -04:00
2023-06-28 23:35:19 -04:00
2023-06-28 23:35:19 -04:00
2023-06-28 23:35:19 -04:00
2026-09-04 13:13:23 -07:00
2026-07-16 07:36:58 -07:00
2025-06-10 23:35:01 -04:00
2023-08-20 22:43:00 -04:00
2023-08-14 00:17:21 -04:00
2023-11-01 18:44:19 -04:00
2024-04-17 23:52:39 -04:00
2023-08-28 00:09:02 -04:00
2024-04-17 23:52:40 -04:00
2023-08-08 00:17:03 -04:00

Pokémon Mystery Dungeon: Explorers of Sky

This is a WIP disassembly of Pokémon Mystery Dungeon: Explorers of Sky. For instructions on how to set up the repository, please read INSTALL.md. For information on how to contribute changes, see CONTRIBUTING.md.

This repository builds the following ROMs:

For contacts and other pret projects, see pret.github.io.

Description
Decompilation of Pokémon Mystery Dungeon: Explorers of Sky
Readme 335 MiB
Languages
Assembly 66.3%
C 18%
C++ 7.1%
Boogie 4.3%
sed 1.5%
Other 2.8%