Skip to content

Repair ten Spanish dialogue rows the reference patch got wrong - #6

Merged
TechnicallyComputers merged 1 commit into
feature/endless-duel-localizationfrom
fix/spanish-dialogue
Sep 4, 2026
Merged

TechnicallyComputers merged 1 commit into
feature/endless-duel-localizationfrom
fix/spanish-dialogue

Conversation

@mstan

@mstan mstan commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

The reported bug was a capture artifact

Spanish second lines were reported as blank. They are not. A pre_quote capture in es showed line 1 complete and line 2 empty, which read as a dropped line; polling the same box with no input shows the real sequence:

t+1.6  L1 |Cumplire mi mision |   L2 |                |
t+2.4  L1 |Cumplire mi mision |   L2 |so              |
t+3.2  L1 |Cumplire mi mision |   L2 |solo si debo!   |

Line 1 settles at ~1.6 s, line 2 starts at ~2.4 s. Spanish rows are shorter than English ones, so they finish earlier and sit in that ~0.8 s gap longer — which is exactly why a fixed-offset capture made the artifact look language-specific. Also disproved along the way: the es_hex payloads were not lossy (fragments-only and full-table replays are byte-identical across all 162 rows), padding style is irrelevant, and the es/en images share identical code.

What is actually broken

Sweeping all 162 rows across all six pages found two Spanish-only defect classes in the imported Max1323 data.

address group before after
0x017900 battle_dialogue_1 Sorry... (English) Lo siento...
0x017e00 battle_dialogue_1 Esta guera parece / halves desynced Esta guerra parece
0x026d00 battle_dialogue_2 We're all incredible (English) Todos somos unos
0x026d80 battle_dialogue_2 fools... (English) tontos increibles...
0x027100 battle_dialogue_2 Sorry, but I don't have (English) Lo siento, pero no tengo
0x027180 battle_dialogue_2 the time for this. (English) tiempo para esto.
0x027580 battle_dialogue_2 ¿Quieres otra? / halves desynced ¿Quieres otra?
0x02c900 battle_dialogue_4 On your feet! (English) ¡En pie!
0x02cf80 battle_dialogue_4 final,¡Soy el vencedor! / halves desynced final,¡Soy el vencedor!
0x02d900 battle_dialogue_4 I fight for Duke Treize! (English) ¡Lucho por el Duque Treize!

Seven rows were never translated. Three encode different text in their top and bottom halves (guera/guerra, Quieres/Quirees, Soy/soy), so from the first divergent column the screen draws the top 8px of one letter over the bottom 8px of another — 11 corrupt cells. decode_reference_tilemaps.py already reported these as bottom-row validation failures; it now reports zero.

0x026c00 looks untranslated but is ...... in every language, so it is left alone. Spanish is written unaccented throughout, which is the reference corpus's own convention (Cumplire, mision) and a hard constraint: es allocates no accent cells, only the inverted marks ¿/¡.

Fix

An es string in endless_duel_dialogue_targets.toml is now an override, re-encoded through encode_line, which derives the bottom tile as top + 0x10 and so cannot desync again. Each override records the es_reference_hex it replaces.

Delivering it requires the generator to own the row outright. A repaired row cannot be co-owned with the imported IPS fragments: they are byte-granular (91 touch these ten rows), they straddle row boundaries, and they do not tile a row — an IPS record exists only where the reference differs from the cart, leaving 81 bytes here covered by nothing. Both partial approaches were built and both fail:

  • rewriting only the fragments' es payload makes the row patch's guard reject the result — a silent no-op whose only symptom is a rising guard-skip count;
  • filling the uncovered bytes with their own patches is worse, because a 1-byte guard matches by coincidence in nearly every language, so a switch strands a handful of Spanish bytes inside the previous language's row.

So the fragments are split around each repaired row (12 split, 79 dropped) and the dialogue patch carries source plus one payload per language — the same split-and-prove generate_intro_caption_patch.py already applies to the caption rectangles.

Validation

All headless.

  • Old-vs-new replay: en, fr, it, pt, tl, id, zh, ko, th and off byte-identical; es differs by 344 bytes, all inside the ten repaired rows. Guard-skips unchanged per language (off improves 163 → 153).
  • --check now replays all ten languages plus off, asserts each of the 162 rows against its expected payload, and walks nine language-switch sequences (es→fr, es→off, off→es, fr→es, en→es, es→ko, ko→es, es→en, off→fr→es→off→es) — switching matters because the engine re-applies rom_patches over the current cart image, so a stale guard fails only after a switch. Seventeen rows that already lost a switch back to Spanish before this work are pinned in KNOWN_SWITCH_LOSS as a burn-down list; any new one fails. 0x02cf80 was on that list and its repair removes it.
  • decode_reference_tilemaps.py --from-table: bottom-row validation failures 3 → 0.
  • Every generator --check green; check_localization.py green; git diff --check clean; generators idempotent (second --write splits 0, drops 0).
  • es dialogue previews now render (its only authored rows are the ten repairs, so the preview is the review sheet).

The intro caption's es digest moves for the second time, documented in place beside the first; en is unchanged.

Docs corrected

Two things this investigation proved wrong: battle_dialogue_0 is a staged surface (it copies to $7f:0000, row stride 0x80), and a fixed-offset capture of a typewriter scene is not evidence — poll until it settles, and never press A in the sampling loop.

🤖 Generated with Claude Code

The reported symptom - Spanish second lines rendering blank - is not a
defect. A pre_quote capture in es showed line 1 complete and line 2 empty,
but that is the inter-line pause: polling the box with no input shows line 1
settling at ~1.6s and line 2 typing from ~2.4s. Spanish rows are shorter than
English ones, so they finish earlier and sit in that gap longer, which is what
made a fixed-offset capture look language-specific. Both lines render.

Sweeping all 162 rows in all six pages did turn up two real Spanish-only
defects, and this fixes them at the source:

* Seven rows the Max1323 patch never translated, still holding the English
  bytes: 0x017900, 0x026d00, 0x026d80, 0x027100, 0x027180, 0x02c900, 0x02d900.
* Three rows whose top and bottom halves encode DIFFERENT text, so from the
  first divergent column the screen draws the top 8px of one letter over the
  bottom 8px of another: 0x017e00 (guera/guerra), 0x027580 (Quieres/Quirees),
  0x02cf80 (Soy/soy). decode_reference_tilemaps.py already flagged these as
  bottom-row validation failures; it now reports zero.

An `es` string in endless_duel_dialogue_targets.toml is now an override that
re-encodes the row through encode_line, which derives the bottom tile as
top + 0x10 and so can never desync again.

Delivering it needs the generator to own the row outright. A repaired row
cannot be co-owned with the imported IPS fragments: they are byte-granular,
they straddle row boundaries, and they do not tile a row, because an IPS
record exists only where the reference differs from the cart. Every partial
scheme was tried and fails - rewriting only the fragments' es payload makes
the row patch's guard reject the result (a silent no-op, visible only as a
rising guard-skip count), and filling the uncovered bytes separately is worse,
since a 1-byte guard matches by coincidence in every language and a switch
strands a few Spanish bytes inside the previous language's row. So the
fragments are split around each repaired row (12 split, 79 dropped) and the
dialogue patch carries source + one payload per language, exactly as
generate_intro_caption_patch.py already does for the caption rectangles.

--check now proves it. It replays the table for all ten languages plus off,
asserts every one of the 162 rows against its expected payload, and walks nine
language-switch sequences, because the engine re-applies rom_patches over the
current cart image - a guard that stops recognising the live row fails only
after a switch. Seventeen rows that already lost a switch back to Spanish
before this work are pinned in KNOWN_SWITCH_LOSS as a burn-down list; any new
one fails the check. 0x02cf80 was on that list and its repair removes it.

Old-vs-new replay: en, fr, it, pt, tl, id, zh, ko, th and off are byte-identical.
es differs by 344 bytes, all inside the ten repaired rows. Guard-skips are
unchanged for every language (off improves 163 -> 153). The intro caption's
es digest moves for the second time, documented in place beside the first.

Also corrects two things this investigation proved wrong in the docs:
battle_dialogue_0 IS a staged surface (it copies to $7f:0000), and a
fixed-offset capture of a typewriter scene is not evidence.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@TechnicallyComputers
TechnicallyComputers merged commit f83cf78 into feature/endless-duel-localization Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants