Skip to content

Walk a Generation 1 map's load body and the rows a fight leaves behind - #604

Merged
Decryptu merged 2 commits into
mainfrom
gen1-map-load-seam
Sep 10, 2026
Merged

Walk a Generation 1 map's load body and the rows a fight leaves behind#604
Decryptu merged 2 commits into
mainfrom
gen1-map-load-seam

Conversation

@Decryptu

Copy link
Copy Markdown
Owner

Changed

  • A Generation 1 map's load-time work is its entry script walked with EnterMap's wCurrentMapScriptFlags bits known set, one walk per mask, kept beside the entry script when it differs. A script's own set on a bit is a map_load_bit node the world hands to the next RunMapScript, which the screen runs on the frame the row's box closes. 30 maps of Red and Blue and 29 of Yellow read differently under a bit, every one whole, against 26 and 24 bodies before: Vermilion City's trash can seed and SS Anne walk, the Game Corner's hideout door, Indigo Plateau's Elite Four reset, Lance's room, Silph Co. 6F, 8F, 10F and 11F among the ones that had not decoded.
  • EndTrainerBattle sets both bits back and leaves the map's script on row 2, so every state table's first three rows are reachable, a state another map's script writes is seeded from that store, and a map with a body of its own on row 2 runs it after a header trainer fight. Red and Blue read 173 state bodies of 362 reachable, Yellow 177 of 361, against 148 of 206 and 156 of 210.
  • The walker reads push bc, pop bc, srl a, adc b, ld d, a, ld e, a, cp c over wCurrentMenuItem, and, add a and srl a on a known byte, a store of a Random byte under its mask (store_byte), the three HRAM temps hGymGateIndex, hGymGateAnswer and hBackupGymGateIndex, a jp onto a special body as a tail call, the routine behind ExecuteCurMapScriptInTable, and a scratch byte handed to hSpriteIndex or hTextID (object_from, map_text from).

Added

  • Vermilion Gym's fifteen trash cans: GymTrashScript as a gym_trash node, the first lock rolled by Vermilion City's load, the second drawn out of the can's GymTrashCans row with the bytes past the table the source's own draws read, and the door opened by VermilionGymSetDoorTile on the frame after the second lock. The three lock bytes ride the world snapshot as gen1_bytes.
  • Cinnabar Gym's six quiz machines: the right answer opens the gate on the spot, the wrong one leaves wOpponentAfterWrongAnswer for CinnabarGymDefaultScript to walk that trainer up and the next state to fight him, on Yellow through the bit his row wants.
  • PokemonTower7FEndBattleScript's rocket saying its line and walking off along the map_coord_movement row the player stands on (object_coord_move), and PokemonTower7FHideNPCScript's loop over wToggleableObjectList.
  • The Champion's Room whole, eleven states from Agatha's own end-battle store, and Pewter City's museum and gym guides.
  • tools/checks/gen1_walk.gd finds both locks and the door, answers a quiz right and wrong and is fought by the trainer the wrong answer brings, fights the tower's rocket and watches it leave, and walks into the Champion's Room and its fight; gen1_maps.gd pins the new censuses.

Fixed

  • _map_script_successors followed only a map's own stores, so the Champion's Room, whose byte Agatha's room writes, kept one state of eleven.
  • _gen1_sight took a map script that only wrote blocks as holding the world, so a gate redrawn behind a fight hid the next sighting.
  • A map_text node over a trainer's row is TalkToTrainer after the fight rather than an empty box.

The entry script is walked with EnterMap's wCurrentMapScriptFlags bits known
set, once per mask, and a script's own set of a bit re-runs that walk on the
next frame; EndTrainerBattle sets both bits and leaves the map's script on row
2, which every table now reaches, along with a state another map's script
writes. Vermilion Gym's trash cans, Cinnabar Gym's quiz, Pokemon Tower 7F's
rockets, the Champion's Room and Pewter City's guides all decode and run.
@Decryptu
Decryptu merged commit fab3497 into main Sep 10, 2026
1 check passed
@Decryptu
Decryptu deleted the gen1-map-load-seam branch September 10, 2026 08:54
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.

1 participant