docs: macros.md 12.35 and macros-wram.md 17 (row 73); the hidden-event list bound covers the Game Corner's 48 entries, checked on the cartridge

This commit is contained in:
acamilo 2026-10-02 02:18:22 +00:00
parent 0caade6b20
commit 872dcfc214
4 changed files with 131 additions and 3 deletions

View file

@ -1077,3 +1077,29 @@ report their cursor (and its `max`) as the entry the same way. The offset is add
list is on screen, because the byte outlives every list. Purchases still use only the first three
rows (`MART_CURSOR_ROWS`, section 7).
## 17. The hidden-event tables (2026-10-02, `docs/design/macros.md` 12.35)
Row 73. Two ROM tables, read through `MemoryReader::read_rom` from the cartridge image the process
already holds, never through the bus and never by switching banks. Pinned the way
`ItemUsePtrTable` is, and read back from the code that uses them by
`row73_the_hidden_event_table_is_the_cartridges_and_bills_pc_is_in_it` (FLY_ROM).
| name | where | what reads it |
| --- | --- | --- |
| `HiddenEventMaps` | `$11:$6A40` | one map id per byte to a `$ff` (85 maps at the pinned commit); the operand of `CheckForHiddenEvent`'s `ld hl, HiddenEventMaps`, followed by `ld a, [hli] / ld b, a / cp $ff` |
| `HiddenEventPointers` | `$11:$6A96` | one little-endian pointer per map of the list above, into the same bank; the operand of the routine's `ld hl, HiddenEventPointers`, followed by `add hl, de` |
Both are in `SECTION "Hidden Events Core"`, which `layout.link` places in bank `$11`. Each map's
list is six bytes an entry to a `$ff` (`hidden_event`): y, x, the routine's argument, and the
routine as `dba` (bank, then a little-endian address). The coordinates are in the same tile space as
`wXCoord`/`wYCoord`, like a sign's.
**`state::hidden_events`** answers the current map's entries as `HiddenEvent { x, y, index,
facing }`: `index` is the entry's position in the map's list, which is how `wHiddenEventIndex`
counts and the talked ledger's key (`TalkTarget::Hidden`); `facing` is the argument when it is a
`SPRITE_FACING_*` value (`$00`, `$04`, `$08`, `$0C`), the side a routine such as `BillsHousePC`
checks. It answers nothing for a map list with no end within 128 entries or an id above `$f7`, a
pointer outside `$4000..$8000`, a list longer than 64 entries (the Game Corner's 48 are the longest), a tile off the loaded map or a
routine address at `$8000` or above. Bill's house (`$58`) has one entry: (1, 4), argument `$04`,
`BillsHousePC` at `$07:$6B6E`.

View file

@ -2155,6 +2155,94 @@ throws),
`row71_a_ball_past_the_bags_window_is_thrown` (`FLY_ROW71_CHECKPOINT`, the live trap) and
`row71_the_list_scroll_offset_is_where_the_cartridge_reads_it` (FLY_ROM).
### 12.35 An errand is its people, then its things, and a hidden event is a thing (2026-10-02, row 73)
Live on v0.7.5, rung 15 (NUGGET BRIDGE), Route 24/25. Scout B3 measured it from the live
checkpoint on six seeds (2.8 brain hours): `GO ROUTE` walked the fly into Bill's house, and inside
it `GO OBJECTIVE` or `GO OUT` walked it straight back out, 30 to 60 times per ten brain minutes.
`GO NPC` was chosen 0 times in about 600 starts in the house, and new tiles stopped (2527 to 2531
in 35 minutes). Rung 16 (MET BILL, `EVENT_GOT_SS_TICKET`) was never earned.
- **The place was the route.** `RUNG_PLACES[16]` was `at(ROUTE_25)`, because the house's id was
not derived. A fly on Route 25 was already "there", so inside the house `GO OBJECTIVE` was an
exit into the objective's own map, which is the same door as `GO OUT`. That is row 29's lab loop
again, one rung later.
- **The rung is an errand, not a conversation.** `scripts/BillsHouse.asm`: Bill (a Pokémon, a
person sprite) asks for help and walks into the teleporter, the cartridge hides his sprite; the
cell separator is started from the PC at (1, 4), pressed facing up; Bill then steps out of the
machine as a second sprite and hands over the ticket. Two people and a thing, in that order.
- **The PC is a hidden event.** `wNumSigns` is 0 in the house and the only sprite is Bill: the PC
is an entry of the cartridge's own hidden-event table (`data/events/hidden_events.asm`), which
`CheckForHiddenEvent` searches on every A in the overworld. No macro could aim at it and `TALK`
was never dealt in front of it, so even a fly that talked to Bill could not earn the rung.
What changed, all of it knowledge inside macros:
- **`PlaceKind::Errand`.** Rung 16's place is `errand(BILLS_HOUSE)` (`$58`, confirmed by Route
25's warp table and by the hidden-event map list). An errand's targets are the room's people,
drawn or off the screen, and once none is left untalked, its things: objects, signs and hidden
events. No step is named anywhere. The cartridge shows and hides the people as the errand moves
on, the talked ledger records what has been had, and what is left is the next step. People come
first because a thing pressed out of turn is in the talked ledger for the session: Bill's PC
pressed before he has asked prints the monitor and does nothing, and a PC recorded as talked to
would never be the next step again. Everything 12.5 and 12.22 give a person place applies: the
ways out are withheld while a target waits, `GO OBJECTIVE` aims at the four sides, facing a
target is the arrival and `TALK` is the press; the blocked ledger is the escape hatch.
- **Hidden events are read from the cartridge's table, not written down.** `state::hidden_events`
walks `HiddenEventMaps` and `HiddenEventPointers` in ROM bank `$11` through
`MemoryReader::read_rom`, the same read the move and item tables use: no WRAM is written and the
mapper's bank register is not touched. The two addresses are pinned from the operands of
`CheckForHiddenEvent`'s own `ld hl` instructions and checked on the cartridge
(`macros-wram.md` section 17); every read checks the table's shape and answers nothing for a
table that is not the one the disassembly describes, which narrows and never invents a tile. A
hard-coded `(1, 4)` would have been a number nobody can check from the running game; the table is
what the cartridge itself consults when the A is pressed.
- **A hidden event is only ever the errand's next step.** It is in `objective_targets` for an
errand and in `facing_target` (so `TALK` is dealt) only while it is that step. It is not added to
`GO ITEM`, `GO NPC` or `TALK` anywhere else. The table holds every PC, poster, trash can,
bookshelf and hidden item in Kanto; making them general targets would add a walk to most
buildings' pads and an entry to the talked ledger for each, which is a change to what the fly is
offered everywhere and not a fix for this trap. The day that is wanted it is one line in
`path::interactable_targets`, and it needs its own survey.
- **A hidden event's side.** Where the entry's argument is a `SPRITE_FACING_*` value it is the side
the routine checks before it does anything (`BillsHousePC` returns unless the player faces up),
so the walk's one aim is the tile on that side and only facing it from there is the arrival and
`TALK`'s precondition. An argument that is an item or a text id and happens to equal a facing
value only narrows the approach.
The fly still chooses every press: `GO OBJECTIVE` to walk, `TALK` to press A, `YES`, `NO` or
`NEXT` in Bill's boxes. Nothing presses for it, no button is added to any pad, and the readout, the
catalog, the adapter and the compatibility string are unchanged. What the scene deals inside the
house is narrower than before, not wider: the ways out leave the pad while the errand waits.
**The road after the ticket (the third trap).** With the ticket the objective is rung 17,
Vermilion, south through Cerulean. Cerulean's ground is in three pieces, not two: the town's ends at
row 28 (the gap at (16, 28) opens onto a wall and the trainer-tips sign), and the south of the map,
the road to Route 5 and the east edge onto Route 9 are reached through the trashed house (`$3e`),
in by its front door at (27, 11) and out by the hole in its back wall onto (27, 9) in the Rocket's
yard. Scout B3 flooded the grid: 378 of the map's 801 walkable tiles are the town's. The house was
off the map graph, so `GO OBJECTIVE` aimed at ground the town cannot reach (`blocked` at (17, 28))
and the fly rang between the town and its houses (0 of 6 seeds past row 28 in 43 brain minutes
each). The house is now on the graph and the south is `SPLIT`'s third piece of Cerulean, so the
objective walks into the house and out through the hole. Before the ticket a guard stands on the
tile in front of the door (`TOGGLE_CERULEAN_GUARD_2`, (27, 12)), which the ticket's own script hides; the objective only
points south after the ticket.
**Not fixed, predicted:** the road from Route 5 to Vermilion on the graph is Route 5, Saffron,
Route 6, as plain map edges. The cartridge's gate houses are guarded until the guard's drink is
given, and the way the game means is the Underground Path, whose houses are off the graph. No run
has reached Route 5's gate yet; it needs its own checkpoint and row.
Tests: `an_errand_is_its_people_first_and_the_room_is_not_left_while_one_is_waiting`,
`a_hidden_event_is_the_errands_next_step_once_no_person_is_left_and_it_is_faced_from_its_side`,
`a_hidden_event_is_nobody_elses_target`, `the_road_south_out_of_cerulean_is_through_the_trashed_house`,
and on the cartridge `row73_the_hidden_event_table_is_the_cartridges_and_bills_pc_is_in_it`,
`row73_the_fly_earns_the_ss_ticket_from_inside_the_ring_at_bills_door`,
`row73_the_cell_separator_pc_is_pressed_and_bill_hands_over_the_ticket`,
`row73_the_fly_walks_from_the_live_route_25_checkpoint_to_the_ss_ticket`,
`row73_the_objective_south_of_cerulean_is_the_trashed_houses_two_doors` and
`row73_the_fly_takes_the_trashed_house_south_to_route_5`.
## 13. Shops and Pokémon Centers (the operator, 2026-09-17: "refactor the shop macros. make it a
## priority to visit the shop at least once per area; make shop macros item purchases. same
## for the Pokécenter. heal should be a macro.")

View file

@ -366,10 +366,11 @@ pub mod poke {
pub const POINTERS_ADDRESS: u16 = 0x6a96;
pub const ENTRY_BYTES: u16 = 6;
/// More maps than the table has (85 at the pinned commit), and more entries than any one
/// map's list (Silph Co.'s and the Game Corner's are the long ones): a walk that runs past
/// either is not walking the table the disassembly describes, and answers nothing.
/// map's list (the Game Corner's 48 slot machines and coins are the longest): a walk that
/// runs past either is not walking the table the disassembly describes, and answers
/// nothing.
pub const MAX_MAPS: u16 = 128;
pub const MAX_ENTRIES: u16 = 32;
pub const MAX_ENTRIES: u16 = 64;
/// `SPRITE_FACING_DOWN`, `_UP`, `_LEFT`, `_RIGHT` (`constants/sprite_data_constants.asm`).
pub const FACINGS: [u8; 4] = [0x00, 0x04, 0x08, 0x0c];
}

View file

@ -5180,6 +5180,19 @@ fn row73_the_hidden_event_table_is_the_cartridges_and_bills_pc_is_in_it() {
let pointers_at =
at(&pointers_load).expect("CheckForHiddenEvent loads HiddenEventPointers from the pinned address");
assert!(pointers_at > maps_at && pointers_at - maps_at < 32, "one routine: {maps_at:#x} {pointers_at:#x}");
// Every map's list ends inside the bounds `state::hidden_events` holds the table to, so no map's
// events are refused for being long (the Game Corner's 48 are the longest).
let byte = |address: u16| bank[usize::from(address - 0x4000)];
let mut maps = 0u16;
while byte(hidden::MAPS_ADDRESS + maps) != 0xff {
assert!(maps < hidden::MAX_MAPS, "the map list ends");
let at = hidden::POINTERS_ADDRESS + 2 * maps;
let list = u16::from_le_bytes([byte(at), byte(at + 1)]);
let entries = (0..).take_while(|entry| byte(list + entry * hidden::ENTRY_BYTES) != 0xff).count();
assert!(entries < usize::from(hidden::MAX_ENTRIES), "map {:#04x}: {entries}", byte(hidden::MAPS_ADDRESS + maps));
maps += 1;
}
assert_eq!(maps, 85, "the pinned commit's 85 maps with hidden events");
let Some(checkpoint) = row73_checkpoint("FLY_ROW73_DOOR_CHECKPOINT") else {
eprintln!("skipped: no FLY_ROW73_DOOR_CHECKPOINT");