Chapter 18: patches, every change we made to the bot
These are the only changes to the bot's own code. Each one is a small diff
of an upstream file, applied at build time (chapter 17), with a comment in
the patched code that starts Carried patch (jev):. Each exists because the
host (chapter 4) could not fix the problem from outside: the bad decision is
made and acted on inside one ap_tick, or sits in one of upstream's static
tables, or between two statements of a static function.
Read in order, they are a fairly good story of what it takes to get from Link's bed to the Pegasus Boots:
flowchart TD bed["Link's house"] -->|"0001: stop walking back down the stairs"| sword["the sword, from uncle"] sword --> ep["Eastern Palace"] ep -->|"0003: the anti-fairy circle is not an enemy to walk into"| bk["the big key ($B8)"] bk -->|"0013: a big chest needs its big key"| bow["the bow, from the big chest"] bow -->|"0004: let the bow shot through"| armos["the Armos Knights"] armos --> pendant["the Pendant of Courage"] pendant -->|"0005: the green pendant is bit 0x04"| sahas["Sahasrahla"] sahas -->|"0006, 0007, 0008: walk up, talk until he gives, close the text"| boots["the Pegasus Boots"] boots -->|"0009, 0010, 0031: dash"| book["the Book of Mudora (wired, not yet proven to land)"]
Aside: two of them undo upstream's own last commit.
bcb2537(2020-02-06) made two changes that broke things its author's earlier video had done fine. One left the bot walking back down every intra-room staircase it had just climbed (0001); the other cleared the Y button on the very frame the bot pressed it to shoot an arrow, so the Armos Knights never took one (0004). Upstream had killed them a month earlier, before the line existed.
Aside: the gap after 0016 is not missing patches. From 0030 the patches came from a separate line of work (movement and combat), numbered apart so that two streams of patches could not collide on a number.
Try it.
lsthis folder, open any patch, and search the patched file forCarried patch (jev). Then build:nix develop -c buck2 build //third-party/c:patchedapplies all of them, in name order, and fails if any no longer applies.
For the people who maintain it
The patches
| Patch | Upstream files | What it changes | Evidence in research/zbanks-alttp.md |
|---|---|---|---|
| 0001 | alttp.c | bcb2537's early return for $B0 != 0 also caught intra-room stairs, which count their steps in $B0; the bot never consumed the targets it climbed past and walked back down. | "The stairs" |
| 0002 | ap_plan.c | ap_goal_choose_hook: a host may make the goal choice. NULL by default, which is upstream exactly. This is where Jev plugs in (chapter 5). | "Jev at the goal choice" |
| 0003 | ap_snes.h, ap_map.c, ap_plan.c | Eastern Palace $B8: the anti-fairy circle is an invulnerable obstacle, not an enemy to walk into; the room gets a kill-all script in upstream's own table; kill-all no longer gives up the first frame an enemy is out of reach. | "Eastern Palace $B8" |
| 0004 | ap_map.c | ap_follow_targets no longer clears the Y that kill-all's bow shot just pressed. | "The Armos Knights" |
| 0005 | ap_req.c | The green pendant is bit 0x04 of $7EF374, as the game and the Randomizer test it; upstream's 0x01 is the red one, which left Sahasrahla unsatisfiable. | "Sahasrahla" |
| 0006 | ap_map.c, ap_plan.c | The bot can walk up to a solid talking NPC (Sahasrahla) and away again. Both exemptions are gated on SPRITE_ATTR_TALK, after the first version made an unrelated sprite transparent to the pathfinder at the castle passage door. | "The boots", "The castle passage door" |
| 0007 | ap_plan.c | A talk lasts until the NPC's text is done and counts only an item actually given, then Link steps off the NPC. | "The boots" |
| 0008 | alttp.c | An open text box always gets A, even while Link is mid-dash. | "The boots" |
| 0009 | ap_map.c | A Pegasus Boots dash for SCRIPT_SEQUENCE: four new characters (8/2/4/6, numpad directions) hold A with a direction, and ap_follow_targets no longer clears a dash's A on plain floor. | "The Book of Mudora" |
| 0010 | ap_map.c, ap_plan.c | A goal for the Library's shelf (room $0107), its approach point derived from ROM data, gated on the boots. Proven to attach and gate; not yet proven to land the book. | "The Book of Mudora" |
| 0011 | ap_snes.h | Room $0123's per-room override for sprite 0xBB/0x0200 keeps SPRITE_ATTR_BLKF, so the pathfinder stops routing through its real hitbox. | "The door D 0x80 stall in room $0123" |
| 0012 | ap_map.c | In the Dam's block-puzzle room ($010B), raw tile 0x27 is a push block, not a hammer peg. | "The Dam Chest push block" |
| 0013 | ap_plan.c | A big chest's goal is unsatisfiable until its dungeon's big key is held. | "The Eastern Palace big chest" |
| 0014 | ap_map.c | Room $0089's north door has no floor before its transition, so its approach point is the door's own tile. | "A door with no vestibule ($0089)" |
| 0015 | ap_map.c | General: a push that jams (push_timer running, Link not moving) marks that cell a wall for the rest of the room visit. | "Never push a block into a wall" |
| 0016 | ap_plan.c | Hyrule Castle routines are done in open mode; any routine whose screen's chests are all open is complete. | "A routine already done, or already claimed, is never offered again" |
| 0030 | ap_map.c | General form of 0012: indoors, raw tile 0x27 is never a hammer peg, by the game's own rule. | "The hammer swings at bare floor" |
| 0031 | ap_snes.h, ap_map.c | With the boots, a path may cross bonk rocks (tile 0x57), and the step onto one is a dash. | not yet written up there |
| 0032 | ap_plan.c | The glove a liftable needs comes from its tile's own LFT1/LFT2 bits, not one hard-coded tile id. | not yet written up there |
CLAUDE.md beside this has each patch's full account: the run, the frame,
the measurement, and why no host fix could do it.
| Path | What |
|---|---|
NNNN-*.patch | The patches, applied in name order by //third-party/c:patched. |
| README.md | This chapter. |
| CLAUDE.md | Every patch's evidence, and the open bugs that are not patches yet. |
← Previous: Chapter 17, c/ · Up: c · Next: Chapter 19, rust/ →