jevsnes.git / third-party / c / patches / 0010-book-of-mudora-goal.patch
0010-book-of-mudora-goal.patch54 lines · 2.8 KB · raw
1diff --git a/third-party/c/zbanks-alttp/ap_map.c b/third-party/c/zbanks-alttp/ap_map.c
2index e481fe75..8a6de043 100644
3--- a/third-party/c/zbanks-alttp/ap_map.c
4+++ b/third-party/c/zbanks-alttp/ap_map.c
5@@ -168,6 +168,32 @@ static const struct ap_script ap_scripts[] = {
6         .name = "Dark cave ledge jump",
7     },
8     */
9+    // Carried patch (jev): the Book of Mudora. Room $0107 ("the Library"),
10+    // reached by entrance $49. start_tl is the entrance's OWN spawn point -
11+    // EntranceData_playerX/Y for $49 in bank_02.asm of
12+    // github.com/JaredBrian/AsarUSALTTPDisassembly is ($0E78,$21D8); ap_map.c's
13+    // indoor X widening (ap_snes.c, ap_sprites_update: "(x&~0x1FF)<<2 |
14+    // (x&0x1FF), +0x4000") turns that into ($7878,$21D8), which matches this
15+    // screen's own tags ("Library v/^ 7800,2100.."). The shelf itself
16+    // (RoomData_Sprites_Room0107, bank_09.asm: `db $15,$03,$3B`, i.e. sprite
17+    // $3B at room-local X=$03*16=$030, Y=$15*16=$150 - two OTHER sprites in
18+    // the same table, at $17/$18,$1B, cross-check that byte order) sits at
19+    // wide (room origin $7800,$2100) + (X=$030,Y=$150) = ($7830,$2250) -
20+    // 72px WEST and 120px SOUTH of the entrance, not the "shelf on the far
21+    // wall opposite the door" a north dash would assume. start_tl walks
22+    // Link (ordinary GOTO_POINT, no dash) to the entrance's own Y but the
23+    // shelf's X, then the sequence dashes SOUTH the ~120px gap with margin.
24+    // DERIVED FROM ROM DATA, NOT YET LIVE-MEASURED: `research/zbanks-alttp.md`
25+    // ("The Book of Mudora") has the live-walk-in this still needs, and the
26+    // reproducible early-game stall (fresh `home`, Jev off, never gets the
27+    // sword) that blocked getting it this session.
28+    {
29+        .start_tl = XY(0x7830, 0x21D8),
30+        .start_item = -1,
31+        .sequence = "2222222222",
32+        .type = SCRIPT_SEQUENCE,
33+        .name = "Library Book of Mudora",
34+    },
35 };
36 
37 static bool add_explore_goals_global = true;
38diff --git a/third-party/c/zbanks-alttp/ap_plan.c b/third-party/c/zbanks-alttp/ap_plan.c
39index 03f78390..880bb246 100644
40--- a/third-party/c/zbanks-alttp/ap_plan.c
41+++ b/third-party/c/zbanks-alttp/ap_plan.c
42@@ -123,6 +123,12 @@ ap_goal_add(enum ap_goal_type type, struct ap_node * node)
43         if (goal->node->script->type == SCRIPT_KILLALL) {
44             ap_req_require(&goal->req, 0, REQUIREMENT_SWORD);
45         }
46+        // Carried patch (jev): the Book of Mudora dash needs the boots -
47+        // there is no other requirement on this script (start_item is -1),
48+        // so without this the goal looks satisfiable with no dash to give.
49+        if (strcmp(goal->node->script->name, "Library Book of Mudora") == 0) {
50+            ap_req_require(&goal->req, 0, REQUIREMENT_BOOTS);
51+        }
52     }
53     /*
54         if (!(type == GOAL_NPC && node->sprite_type == 0x73 && node->sprite_subtype == 0x100)) {