Skip to content

fix(asset tools, Windows): write dungeon maps in binary mode ("w" → "wb"); Windows text mode shifted 462 map offsets - #214

Merged
999sian merged 1 commit into
999sian:masterfrom
Strikeborn:fix/dungeonmap-binary-mode
Oct 20, 2026
Merged

999sian merged 1 commit into
999sian:masterfrom
Strikeborn:fix/dungeonmap-binary-mode

Conversation

@Strikeborn

@Strikeborn Strikeborn commented Oct 7, 2026 •

Copy link
Copy Markdown

Result: on Windows, the asset tool wrote one binary dungeon map in text mode, so it grew from 64 to 67 bytes. The full build then recalculated every later map offset from file sizes, shifting 462 of them by 4 bytes. The game was compiled pointing at the wrong ROM data for late-game pause-screen dungeon maps and the Gyorg boss arena. Writing the file in binary mode keeps every offset matching the ROM.

The fix is one character, "w" → "wb". On Linux and macOS, text and binary mode write identical bytes, so the line was always correct there. Only Windows translates 0x0A into 0x0D 0x0A in text mode, so "wb" makes Windows behave the way Linux already does, with no change on other platforms.

Files: tools/src/asset_processor/assets/dungeonmap.cpp (1 line)

Cause

DungeonMapAsset::buildToBinary() writes PalaceOfWinds_DarknutMiniboss/dungeon_map.bin (64 bytes, three 0x0As) with "w", so Windows writes 67. build_assets then recomputes offsets from rebuilt sizes (67 → aligned 68) and overwrites build/USA/assets/map_offsets.h. 462 of 1,846 offsets, from PalaceOfWinds_BombWallInside on, move by +4. Slim builds and release CI never run this step.

The "w" dates from zeldaret/tmc (2022), where it's harmless: the decomp builds a new ROM from the same files, normally on Linux. Picori builds the tools on Windows and reads map data from the original ROM through these offsets.

It also persists. The 67-byte file overwrites the extracted one, and the next convert_assets reads it back into dungeon_map.txt, so the corruption spreads into the editable files too. On an affected Windows tree, 8 Palace of Winds dungeon maps didn't match the ROM even after the one-character fix. Extraction skips files that already exist, so they stay wrong until re-extracted (#218 forces a re-extract when asset inputs change, which heals such trees).

Effect in game (late game only)

  • Pause-screen dungeon maps (src/common.c: Palace of Winds, Dark Hyrule Castle, others) draw shifted or garbled.
  • The Gyorg fight (src/enemy/gyorgFemale.c) decompresses its arena from the wrong start, giving wrong tiles and collision, possibly a softlock. The bounded LZ77 decompressor prevents a crash. Rooms loaded from the extracted area tables are unaffected.

Verified

Each offset was checked in the USA ROM for the LZ77 header byte (0x10):

map_offsets.h Changed room-map entries matching the ROM
Committed 295 / 295
Regenerated on Windows, before fix 4 / 295
Regenerated on Windows, after fix identical to committed

Play-tested to the Picori Festival (early game only). The affected rooms come later, so this rests on the ROM check.

Suggestion

build_assets overwriting a tracked header with sizes from rebuilt files is fragile for the PC port. Build mode could write elsewhere, or fail if its offsets differ from extract mode's.


Developed with assistance from Claude Code (Opus 5.5). I reviewed and tested the changes as described above.

Text mode turned 0x0A into 0x0D 0x0A on Windows, growing a 64-byte dungeon map to 67 bytes and shifting 462 offsets in map_offsets.h by +4 in full builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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