jevsnes.git / third-party / c / patches

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. ls this folder, open any patch, and search the patched file for Carried patch (jev). Then build: nix develop -c buck2 build //third-party/c:patched applies all of them, in name order, and fails if any no longer applies.

For the people who maintain it

The patches

PatchUpstream filesWhat it changesEvidence in research/zbanks-alttp.md
0001alttp.cbcb2537'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"
0002ap_plan.cap_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"
0003ap_snes.h, ap_map.c, ap_plan.cEastern 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"
0004ap_map.cap_follow_targets no longer clears the Y that kill-all's bow shot just pressed."The Armos Knights"
0005ap_req.cThe 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"
0006ap_map.c, ap_plan.cThe 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"
0007ap_plan.cA talk lasts until the NPC's text is done and counts only an item actually given, then Link steps off the NPC."The boots"
0008alttp.cAn open text box always gets A, even while Link is mid-dash."The boots"
0009ap_map.cA 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"
0010ap_map.c, ap_plan.cA 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"
0011ap_snes.hRoom $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"
0012ap_map.cIn the Dam's block-puzzle room ($010B), raw tile 0x27 is a push block, not a hammer peg."The Dam Chest push block"
0013ap_plan.cA big chest's goal is unsatisfiable until its dungeon's big key is held."The Eastern Palace big chest"
0014ap_map.cRoom $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)"
0015ap_map.cGeneral: 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"
0016ap_plan.cHyrule 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"
0030ap_map.cGeneral form of 0012: indoors, raw tile 0x27 is never a hammer peg, by the game's own rule."The hammer swings at bare floor"
0031ap_snes.h, ap_map.cWith the boots, a path may cross bonk rocks (tile 0x57), and the step onto one is a dash.not yet written up there
0032ap_plan.cThe 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.

PathWhat
NNNN-*.patchThe patches, applied in name order by //third-party/c:patched.
README.mdThis chapter.
CLAUDE.mdEvery patch's evidence, and the open bugs that are not patches yet.

← Previous: Chapter 17, c/ · Up: c · Next: Chapter 19, rust/ →