Repository navigation
Conversation
region_symbols.py now retries every unplaced EU C function at the address given by the shift of the placed functions on either side, which finds functions that follow a run of regional differences. make REGION=usa compare: OK, 1265 C intervals (1245 relocated), 165792 bytes. make REGION=jp compare: OK, 1270 C intervals (1227 relocated), 164410 bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The regional build now compiles src/*.c once more with -DREGION_<REGION> (Makefile REGION_CPPFLAGS, build/regions/<region>/variant) and pairs and relocates the functions of that build, translating keys back to EU addresses by name. Without regional blocks the variant equals EU. include/region.h describes the USA player record (0x158 bytes, fields from EU +0x0C moved by 10, from +0x2A by 12) as PLAYER_SIZE/PLAYER_FIELD; struct Player uses them, and sub_08015C5C now addresses the record through them. make compare: OK. make REGION=usa compare: OK, 1329 C intervals (1309 relocated), 187424 bytes. make REGION=jp compare: OK, 1272 C intervals (1229 relocated), 164414 bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tools Adds SAVE_FIELD for the USA character save record and writes player/save offsets of shared EU functions and player-record struct views through PLAYER_FIELD/SAVE_FIELD/PLAYER_SIZE. The macros are the identity in EU. New tools: region_diff.py (rank/diff unplaced functions against the USA ROM), region_autofix.py (macro search on literals), region_structs.py (regional pad sizes for 0x14C-byte struct views). make compare: OK. make REGION=usa compare: OK, 1364 C intervals (1344 relocated), 197914 bytes. make REGION=jp compare: OK (unchanged). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
region_autofix.py --max-diff 16 rewrote player/save offsets of 34 more functions; adds ENEMY_SIZE (EU 0x2E0, USA 0x454) and lets autofix try it. make compare: OK. make REGION=usa compare: OK, 1398 C intervals (1378 relocated), 216232 bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed targets region_autofix.py --max-diff 48 rewrote 13 more functions, 12 of them with ENEMY_SIZE. region_build.py now calls BL targets that are also stored as .word data through a <name>__bl .thumb_set alias, so the data word keeps the Thumb bit (a .word of a .thumb_set symbol drops it). make compare: OK. make REGION=usa compare: OK, 1411 C intervals (1391 relocated), 221274 bytes. make REGION=jp compare: OK (unchanged). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
make compare: OK. make REGION=usa compare: OK, 1421 relocated EU functions (+30). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
make compare: OK. make REGION=usa compare: OK, 1445 C intervals (1425 relocated), 226872 bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ss search region_diff guesses now also try addresses where a function's opening non-relocated bytes recur near each neighbour guess (literal pool shifts); region_autofix widens SAVE_FIELD to save offsets up to 0x1000; region_structs resizes 0x2E0 enemy record views to ENEMY_SIZE. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tions) (T *)0x03XXXXXX literals become &gUnk_03XXXXXX so that the regional build relocates them; EU bytes unchanged. region_autofix also tries field macros on size-valued literals; region_diff lists the counted differing halfwords. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tions) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed functions) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
USA inserts 0x174 bytes at enemy record +0x206 (0x2E0 + 0x174 = 0x454): 0x1CE/0x1DC/0x1FD/0x201/0x204 keep their offsets, 0x206..0x22F move. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…shared functions) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tions) region_structs --partial maps smaller structs as prefix views of a player, save or enemy record (kept only with an exact gain); region_autofix tries every candidate literal of one macro at once before single moves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l literal 2s Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(10 more shared functions) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… autofix (12 more shared functions) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ared functions) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d functions) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ze (10 more shared functions) PLAYER_FIELD inserts the 2 extra bytes before EU +0x30 (EU +0x2E maps to USA +0x38). Autofix logs its best partial rewrite; region_structs treats short byte arrays as pads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ore shared functions) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tart state (6 more shared functions) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…shared functions) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ced functions (5 more shared functions) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ore shared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… more shared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… more shared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… shared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… more shared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unction) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e shared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… shared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… shared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…1 more shared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…shared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ction) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… shared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…re shared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…more shared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… (2 more shared functions) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… shared function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Continues the USA regional build on top of #827. All USA game code now builds from C: every EU C function with a USA counterpart is placed through
tools/config/region_symbols_usa.json, apart from one kept as region-only code (below).sub_0800B7DC, its wrappersub_0800BCFC, andsub_08091F20do not exist in USA (their USA neighbours are adjacent).sub_080663A4stays region-only: the USA version sits elsewhere in link order.usa_only.c. The 16-bit-text number helper (USA080813D8) is now theREGION_USAbranch ofsub_080850C0.Not included: data is still taken from the USA ROM, the USA layout is not shiftable, and some USA bodies still use register pins or empty
asmstatements to match.How
All source differences live behind
#ifdef REGION_USAor in the layout macros ofinclude/region.h, which are the identity in the EU build, so EU output is unchanged.PLAYER_FIELD/SAVE_FIELD. The save block starts with a 16-bit name.ENEMY_FIELD/ENEMY_DATA_FIELD. The enemy record embedded at +0x204, and the enemy-data/job tables, carry a 0x174-byte prefix in USA.ITEM_FIELD/EQUIP_FIELD, plusEQUIP_E_FIELD(archive 0xE records shift by 0xE0).RES_ID,TEXT_HEADER,TextChar/NameChar.sub_0801BA74, and an extra direction check in the player task's state 5 (sub_0800D368).0x14C/0x2E0values that an earlier pass had turned intoPLAYER_SIZE/ENEMY_SIZEare restored.region_symbols.pyplaces functions with assembler-resolved references by pinning them to the function's own shift; the regression test that expected them to be rejected now checks this. Newregion_permute.pyruns decomp-permuter against the regional ROM;region_autofix.pygains--addresses.Some commits are partial: layout fixes that cut a function's diff without placing it yet. Their messages say so.
Checks
make compare:shiningsoul2_eu.gba: OKmake REGION=usa compare:shiningsoul2_usa.gba: OKmake nonmatching: buildscheck_tree.py: 0 errors🤖 Generated with Claude Code