docs: row 69, throw on low HP only and the fly names its catch

macros.md 12.32 and the 13.1 table rows; macros-wram.md 15 (the two
naming bytes); feed-protocol: padEmptyMs is 0 on the keyboard;
macros-traps row 69 with the ROM tests and the connectome survey.
This commit is contained in:
acamilo 2026-09-29 18:46:11 +00:00
parent 0d444bb00f
commit 3c72967a5b
4 changed files with 149 additions and 3 deletions

View file

@ -1024,3 +1024,22 @@ the latch keeps that A until the next list first asks. Measured on the Potion's
list reads open on the frame after the pulse, an A in the next 22 frames is lost, and across 120 list reads open on the frame after the pulse, an A in the next 22 frames is lost, and across 120
rollback delays `hJoyLast`, `hJoyPressed`, `hJoyHeld` and `hJoy5` are the only bytes of WRAM and rollback delays `hJoyLast`, `hJoyPressed`, `hJoyHeld` and `hJoy5` are the only bytes of WRAM and
HRAM whose values never overlap between lost and answered frames. HRAM whose values never overlap between lost and answered frames.
## 15. The naming screen (2026-09-29, `docs/design/macros.md` 12.32)
Row 69. Two bytes of a `UNION` in `ram/wram.asm` that the reviewed list does not carry, pinned the
way `hJoyLast` is and read back from the code that stores them by
`row69_the_naming_bytes_are_where_the_cartridge_stores_them` (FLY_ROM).
| name | where | what reads it |
| --- | --- | --- |
| `wNamingScreenNameLength` | `$CEE9` | the letters typed; the operand of `PrintNicknameAndUnderscores`'s `ld [wNamingScreenNameLength], a` before `hlcoord 10, 2` |
| `wNamingScreenSubmitName` | `$CEEA` | non-zero once START or ED is taken; the operand of `.pressedStart`'s `ld [wNamingScreenSubmitName], a` |
**`state::naming_screen`** is the keyboard only when the menu bytes `DisplayNamingScreen` writes
(`wTopMenuItemY` 3, `wMaxMenuItem` 7, `wMenuWatchedKeys` `$ff`) **and** its figure are on screen:
the whole `TextBoxBorder` at (0, 4)-(19, 14) and a run of seven or ten underscores (`$76`, the raised
one `$77`) from (10, 3). The run's length is the capacity (`PLAYER_NAME_LENGTH - 1` or
`NAME_LENGTH - 1`). The menu bytes outlive the screen, so both halves are needed, as for
`yes_no_prompt`. The player's and rival's names at the start of a game are this screen before
`wStatusFlags6`'s game-timer bit is set, and `scene::detect` answers `Title` for them first.

View file

@ -1971,6 +1971,76 @@ Nothing ranks a button or presses for the fly. The walk back is withheld for a w
is one offer, and the bag is read off the screen. The decoder, the reward catalog, the adapter is one offer, and the bag is read off the screen. The decoder, the reward catalog, the adapter
version, the roles and the compatibility string are untouched. version, the roles and the compatibility string are untouched.
### 12.32 A ball at low HP is the only attack, and the fly spells its catch's name (2026-09-29, row 69)
(12.31 is row 67.) Two operator decisions of 2026-09-29, after row 66 measured the connectome
choosing `THROW BALL` 0 times in 35 decisions with a ball in the bag, and every catch named
`AAAAAAAAAA` by `NEXT`'s A presses on the keyboard.
**"Throw on low HP only."** In a wild battle, when `THROW BALL` is on the pad and the wild
Pokémon's HP is low, the ball is the only attack-side button: `MOVE 1` to `MOVE 4` are withheld on
the top-level menu, and so are `SWITCH` and `RUN`, and `BACK` in the bag.
- **Low is the cartridge's number.** `ItemUseBall` (`engine/items/item_effects.asm`) computes
`W = (MaxHP * 255 / BallFactor) / max(HP / 4, 1)`, floored at each step, with a `BallFactor`
of 8 for a Great Ball and 12 for every other. The ball holds on HP when a random byte is at most
`W`, so at `W >= 255` HP stops mattering. For a Poké Ball that is HP at about a third of its
maximum (7 of a Weedle's 20), for a Great Ball about a half. Lower HP buys nothing more; what is
left is the catch rate and the status, which no press changes. So low is where the throw stops
getting better (`palette::ball_holds_on_hp`, `palette::throw_only`), for the ball
`THROW BALL` would throw.
- **What stays beside the ball.** `ITEM`, because it is dealt only for a Pokémon that is out,
under half its HP, with a Potion the cartridge would take: the one non-attack need that keeps
the thrower standing. `SWITCH` is about a healthier fighter; `RUN` forfeits the catch the pad
exists for, with the enemy at its weakest; `BACK` in the bag leads to a menu whose pad is the
same ball. `palette::WITHHELD_FOR_THE_THROW` is the list.
- **It cannot loop.** It applies only while `THROW BALL` itself is dealt, so every precondition
of that button still holds it: a wild battle, a ball, room in the party, a species the party does
not hold. A missed throw is an ordinary turn (`NEXT` between turns, the ball again on the next
own turn while one is left). With no ball left the button is off the pad and so is the rule, and
the moves are back. An enemy that faints ends the battle as always. A catch goes to the nickname
offer, which `NEXT` answers YES as before.
**"Let the fly name it."** The keyboard (`DisplayNamingScreen`) is a screen of its own. It reads
`Unknown` in or out of a battle (the detector checks it before `wIsInBattle`), and its pad is the
fly's **own buttons**: the D-pad moves over the letters, A types one (or ED, which hands the name
back, or the case switch), B deletes, START hands the name back. SELECT is not on the operator's
list and is masked. No macro is dealt while the fly spells.
- **Why raw buttons and not a macro per key.** A macro per key is new types, and a new type
re-deals every macro population (`docs/readout.md`). The fly's raw buttons are already decoded
every frame in macros mode, and the title already passes them through (section 2). The player's
and rival's names at the start of a game are the same screen before the game timer starts, so
they read `Title` and the fly has always typed them with these buttons; the nickname is now
consistent with them. `Observed::raw` carries the scene's mask and the layer presses
`raw_mask & raw` while nothing is bound and nothing runs.
- **The bound.** Once the name is full (`wNamingScreenNameLength` at the capacity the underscores
show, ten or seven; the cartridge moves the cursor onto ED itself then), or sixty brain seconds
after the keyboard opened (`palette::NAMING_BOUND_MS`), the raw buttons are shut and `CONFIRM`
is the only button. On the keyboard `CONFIRM` pulses START until the screen is gone
(`Step::Submit`), `blocked` after 160 frames. `CONFIRM` is not offered earlier: a macro group of
one always has a winner at its next decision, so a lone `CONFIRM` would hand back an empty name
within a second.
- **What the name is.** Whatever the fly typed stays. An empty name is the species' own name,
which is the cartridge (`AskName.declinedNickname`).
- **The reading.** Red has no "keyboard open" byte, so `state::naming_screen` is the construction
`yes_no_prompt` makes: the menu bytes `DisplayNamingScreen` writes (`wTopMenuItemY` 3,
`wMaxMenuItem` 7, every key watched), the keyboard's whole box at (0, 4)-(19, 14), and the
underscores at (10, 3). `wNamingScreenNameLength` (`$CEE9`) and `wNamingScreenSubmitName`
(`$CEEA`) are read from the operands of the cartridge's own instructions, like `hJoyLast`, and
pinned by the ROM tests.
- `game.scene` is `unknown` on the keyboard, `game.palette` is `[]` while the fly spells, and
`game.padEmptyMs` stays 0: the fly's own buttons are a pad.
ROM tests (`tests/rom_catch.rs`): `row69_at_low_hp_a_wild_battles_pad_is_the_ball`
(`FLY_ROW69_CHECKPOINT`), `row69_after_a_catch_the_keyboard_is_the_flys_own_buttons_and_it_ends`
and `row69_a_fly_that_types_nothing_is_ended_by_the_bound` (`FLY_CATCH_CHECKPOINT`). Survey
numbers are in `infra/docs/macros-traps.md` row 69.
Nothing presses for the fly on the keyboard but the bound's one button, dealt as a button and
chosen by the fly's own macro group. The decoder, the reward catalog, the adapter version, the
roles and the compatibility string are untouched.
## 13. Shops and Pokémon Centers (the operator, 2026-09-17: "refactor the shop macros. make it a ## 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 ## 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.") ## for the Pokécenter. heal should be a macro.")
@ -2051,7 +2121,9 @@ observe is not a precondition, it is a guess.
| Dialog, a readable YES/NO box (**the box the cartridge drew**, 12.20) | YES, NO — or **one of them** at a Pokémon Center's nurse | **new, 12.12.** `NEXT` is off it: an A press at a two-option menu confirms the option the cursor is on, which is what `YES` is, so the two are one press under two names (12.10). At the nurse's own prompt the bound answer is the one that changes something — `YES` with a hurt or statused party, `NO` with a full one. An answer whose prompt comes straight back is excluded for the blocked window, and the exclusion never empties the pad | | Dialog, a readable YES/NO box (**the box the cartridge drew**, 12.20) | YES, NO — or **one of them** at a Pokémon Center's nurse | **new, 12.12.** `NEXT` is off it: an A press at a two-option menu confirms the option the cursor is on, which is what `YES` is, so the two are one press under two names (12.10). At the nurse's own prompt the bound answer is the one that changes something — `YES` with a hurt or statused party, `NO` with a full one. An answer whose prompt comes straight back is excluded for the blocked window, and the exclusion never empties the pad |
| Menu (the start menu) | CLOSE, CONFIRM, BACK | unchanged as a *scene*, and since **12.11** nothing on any other pad opens it: the fly reaches it with the **raw** START button, which still reaches the cartridge in macros mode, and moves its cursor with the raw D-pad. A SAVE or a POKéDEX button would be a macro per start-menu entry and is not asked for -- which is precisely why `MENU` had nothing behind it | | Menu (the start menu) | CLOSE, CONFIRM, BACK | unchanged as a *scene*, and since **12.11** nothing on any other pad opens it: the fly reaches it with the **raw** START button, which still reaches the cartridge in macros mode, and moves its cursor with the raw D-pad. A SAVE or a POKéDEX button would be a macro per start-menu entry and is not asked for -- which is precisely why `MENU` had nothing behind it |
| Menu (the bag, an elevator, the party list outside a battle) | CLOSE, CONFIRM, BACK | unchanged | | Menu (the bag, an elevator, the party list outside a battle) | CLOSE, CONFIRM, BACK | unchanged |
| Unknown (the Pokédex, the trainer card, OPTION, a naming screen, a mid-warp frame) | NEXT, **BACK** | **BACK added** (row 9): B is what leaves the first three, and A leaves none of them | | Unknown (the Pokédex, the trainer card, OPTION, a mid-warp frame) | NEXT, **BACK** | **BACK added** (row 9): B is what leaves the first three, and A leaves none of them |
| Unknown, the naming screen (**12.32**) | the fly's own D-pad, A, B and START; **CONFIRM** alone once the name is full or after sixty brain seconds | new, row 69: read before the battle test, so a nickname typed in a battle is here too |
| Battle, own turn, main menu, a wild Pokémon at low HP with THROW BALL dealt (**12.32**) | THROW BALL, and ITEM for a hurt thrower | new, row 69: the moves, SWITCH and RUN withheld; the bag's BACK too |
| Battle, own turn, main menu | MOVE 1..4, SWITCH, ITEM, THROW BALL, RUN (whose cursor indices are FIGHT 0, **ITEM 1, PKMN 2**, RUN 3 -- two columns, 12.11) | four move buttons for `ATTACK` (section 14); THROW BALL added, and gated on the species since 12.9; **RUN gated**, below. No `BACK`: the four entries are the answers to this menu. **`NEXT` removed by 12.10** — an A press here confirms FIGHT and reopens the list the move list's `BACK` just closed, and `MOVE 1` is the backstop instead, bound here whatever the battler reads as | | Battle, own turn, main menu | MOVE 1..4, SWITCH, ITEM, THROW BALL, RUN (whose cursor indices are FIGHT 0, **ITEM 1, PKMN 2**, RUN 3 -- two columns, 12.11) | four move buttons for `ATTACK` (section 14); THROW BALL added, and gated on the species since 12.9; **RUN gated**, below. No `BACK`: the four entries are the answers to this menu. **`NEXT` removed by 12.10** — an A press here confirms FIGHT and reopens the list the move list's `BACK` just closed, and `MOVE 1` is the backstop instead, bound here whatever the battler reads as |
| Battle, own turn, move list (**the box on screen**, 12.18) | MOVE 1..4, BACK -- or **MOVE 1 alone** | as above, plus **12.11**: `BACK` is dealt here only while `wBattleMon*` reads, because a list that binds no `MOVE n` has a pad whose one button closes the list `MOVE 1` underneath had just opened. With nothing readable the pad is `MOVE 1` and its script confirms where the cursor stands | | Battle, own turn, move list (**the box on screen**, 12.18) | MOVE 1..4, BACK -- or **MOVE 1 alone** | as above, plus **12.11**: `BACK` is dealt here only while `wBattleMon*` reads, because a list that binds no `MOVE n` has a pad whose one button closes the list `MOVE 1` underneath had just opened. With nothing readable the pad is `MOVE 1` and its script confirms where the cursor stands |
| Battle, own turn, party list | SWITCH, BACK | unchanged | | Battle, own turn, party list | SWITCH, BACK | unchanged |
@ -2102,7 +2174,7 @@ measured where it cannot.
| a running macro aborts and the pad is not re-dealt until the next frame | not a cause: `observe` runs after every frame and the decoder is handed the bound channels again on the very next one | | a running macro aborts and the pad is not re-dealt until the next frame | not a cause: `observe` runs after every frame and the decoder is handed the bound channels again on the very next one |
| a restore, before the first `observe` | not a cause: the loop calls `observe` once at the end of boot and once after a ratchet recovery, so the first frame is decided on a real palette | | a restore, before the first `observe` | not a cause: the loop calls `observe` once at the end of boot and once after a ratchet recovery, so the first frame is decided on a real palette |
| the title screen, and raw mode | not an empty pad by contract: the readout's boot variant applies and no palette is dealt | | the title screen, and raw mode | not an empty pad by contract: the readout's boot variant applies and no palette is dealt |
| a scene the detector cannot name | `Unknown` deals `NEXT` and `BACK`; a screen neither press leaves (the naming screen, row 14) is a genuine stall and still needs START, which is a contract change | | a scene the detector cannot name | `Unknown` deals `NEXT` and `BACK`. The naming screen (row 14), which neither press leaves, is read since **12.32** and its pad is the fly's own buttons, then `CONFIRM` (START) once the name is full or the bound runs |
| an `Unknown` frame that is the **overworld with the cartridge driving** -- a warp in flight, a scripted push-back, a guide walking the fly through a door | **empty on purpose** (12.13). There is no box to advance and no screen to leave, so an A or a B press is a press into somebody else's script: it changes nothing and completes where the fly stands. This is the one empty pad that ends itself -- the cartridge gives the buttons back within a few frames -- and `game.padEmptyMs` reports it like any other | | an `Unknown` frame that is the **overworld with the cartridge driving** -- a warp in flight, a scripted push-back, a guide walking the fly through a door | **empty on purpose** (12.13). There is no box to advance and no screen to leave, so an A or a B press is a press into somebody else's script: it changes nothing and completes where the fly stands. This is the one empty pad that ends itself -- the cartridge gives the buttons back within a few frames -- and `game.padEmptyMs` reports it like any other |
| the fly's own turn while the cartridge holds the A it last took (`hJoyLast`) | **empty on purpose** (12.27): a menu the game is acting on or has not started reading. Ends itself on the game's next joypad read | | the fly's own turn while the cartridge holds the A it last took (`hJoyLast`) | **empty on purpose** (12.27): a menu the game is acting on or has not started reading. Ends itself on the game's next joypad read |
| the fly's own turn where the seam cannot read the battler, now that `NEXT` is off that row (12.10) | **fixed**: `MOVE 1` is bound over the top-level menu whatever `wBattleMon*` reads as, because FIGHT is one of that menu's four entries and always opens | | the fly's own turn where the seam cannot read the battler, now that `NEXT` is off that row (12.10) | **fixed**: `MOVE 1` is bound over the top-level menu whatever `wBattleMon*` reads as, because FIGHT is one of that menu's four entries and always opens |

View file

@ -187,7 +187,8 @@ before. The Rust producer always sends all five, in both modes.
- **`game.padEmptyMs`** is how long the pad has had nothing on it **in a playable scene**, in - **`game.padEmptyMs`** is how long the pad has had nothing on it **in a playable scene**, in
brain milliseconds, and 0 otherwise — in raw mode, on the title screen, when something is bound, brain milliseconds, and 0 otherwise — in raw mode, on the title screen, when something is bound,
and while a macro is running, because a running macro owns the pad. It is **report only**: no on the naming screen, whose pad is the fly's own buttons (`docs/design/macros.md` 12.32), and
while a macro is running, because a running macro owns the pad. It is **report only**: no
producer acts on it and no consumer should, and nothing in the loop reads it back. It exists producer acts on it and no consumer should, and nothing in the loop reads it back. It exists
because an empty pad is the doctrine working — nothing presses for the fly, so a scene with no because an empty pad is the doctrine working — nothing presses for the fly, so a scene with no
button waits — and on screen that is indistinguishable from a hang button waits — and on screen that is indistinguishable from a hang

View file

@ -3430,3 +3430,57 @@ button.
`TALK` at a counter: 0 of 12 decisions on either arm. The floor `BUY BALL`: chosen 3 of 13, and `TALK` at a counter: 0 of 12 decisions on either arm. The floor `BUY BALL`: chosen 3 of 13, and
done (paid) all 3 times. The ring: 4 mart entries in 16 brain seconds on base, one visit on the done (paid) all 3 times. The ring: 4 mart entries in 16 brain seconds on base, one visit on the
branch. branch.
## 2026-09-29, row 69: throw on low HP only, and the fly names its catch
### What was asked
Two operator decisions after row 66 (`docs/design/macros.md` 12.32). Row 66 measured the connectome
choosing `THROW BALL` 0 times in 35 decisions with a ball in the bag (66e), and every catch named
`AAAAAAAAAA`: `NEXT` answered the nickname offer YES and its A presses typed on the keyboard (66d).
| # | trap | trigger | test | fix, or why it is left |
| --- | --- | --- | --- | --- |
| 69 | at low HP the ball sat beside four moves, `SWITCH` and `RUN`, and the fly never chose it (66e) | a wild battle with a ball, the enemy at a third of its HP | `row69_at_low_hp_in_a_wild_battle_the_ball_is_the_only_attack` and four more unit tests, `row69_at_low_hp_a_wild_battles_pad_is_the_ball` (`FLY_ROW69_CHECKPOINT`) | **operator decision, built**: with `THROW BALL` dealt and `ItemUseBall`'s HP factor saturated (`W >= 255`), the moves, `SWITCH`, `RUN` and the bag's `BACK` are withheld; `ITEM` stays for a hurt thrower |
| 69b | the keyboard read as the battle's between-turns frame, so `NEXT` typed the name (66d) | every catch | `row69_after_a_catch_the_keyboard_is_the_flys_own_buttons_and_it_ends`, `the_naming_screen_is_its_menu_and_its_box_and_its_underscores` | **operator decision, built**: the keyboard reads `Unknown` and its pad is the fly's own D-pad, A, B and START |
| 69c | a keyboard nobody ends is a stall: B never leaves it and A stops typing at ten letters | a fly that does not press ED or START | `row69_a_fly_that_types_nothing_is_ended_by_the_bound`, `row69_confirm_on_the_keyboard_presses_start_until_it_closes` | **fixed**: once the name is full or sixty brain seconds have run, `CONFIRM` alone, which presses START until the keyboard closes (`blocked` after 160 frames) |
| 69d | row 66's `unknown_pads_with_no_box` counted the bound's `CONFIRM` on the keyboard, which is drawn without the text font | the rung-10 Pewter gym drive, which buys a ball and catches | `the_fly_reaches_the_pewter_gym_from_the_rung_ten_checkpoint` | **fixed in the test**: the keyboard is a drawn screen |
| 69e | the catch checkpoint's lead one-shots every forest Pokémon, so no wild HP is ever low there | `FLY_CATCH_CHECKPOINT` | -- | **left, named**: the low-HP ROM test uses a rung-9 Route 2 checkpoint (rung-9 A below: a Bulbasaur at 5/30, one ball) as `FLY_ROW69_CHECKPOINT` |
### Before and after
ROM tests (rom-env sourced, the build box), a69a258 against the branch:
| test | a69a258 | branch |
| --- | --- | --- |
| `row69_at_low_hp_a_wild_battles_pad_is_the_ball` | 664 low-HP frames with the ball dealt, pad `MOVE 1`, `MOVE 2`, `MOVE 3`, `THROW BALL`. **Fails** | 58 frames, pad `THROW BALL` alone, thrown. Passes |
| `row69_after_a_catch_the_keyboard_is_the_flys_own_buttons_and_it_ends` | keyboard 511 frames, 11 `NEXT` starts, 0 raw frames, name `AAAAAAAAAA`. **Fails** | keyboard 1,516 frames, no macro, 1,516 frames of the fly's buttons, 7 letters at most, name `RIJ?`, closed by the fly (ED). Passes |
| `row69_a_fly_that_types_nothing_is_ended_by_the_bound` | `NEXT` types ten A's and ED. **Fails** | nothing typed; `CONFIRM` dealt once at the bound, span 3,587 frames, name empty (the species' own). Passes |
| `row66_after_a_catch_the_pad_is_not_the_bag_and_the_battle_ends` | passes | passes (battle over 2,468 frames after the catch) |
With the connectome (`trap_hunt`, one sweep thread, 15 brain minutes, macro log). The runs vary the
starting state, as row 66's did: four rung-9 checkpoints with one ball each.
| checkpoint (lead, balls) | arm | wild battles with a ball | `THROW BALL` dealt frames / chosen | the throw's pad (frames) | catches | keyboard | rung, tiles, windows flagged |
| --- | --- | ---: | ---: | ---: | ---: | --- | --- |
| rung-9 A, Route 2 (Bulbasaur 5/30, 1) | a69a258 | 5 | 414 / 0 | -- | 0 | -- | 10, 520, 40 |
| | branch | 2 | 96 / 1, at low HP from the pad `THROW BALL` alone | 32 | 1 | 16.8 brain s, A 32, B 30, longest 1, name empty (the species'), ended by the fly (ED) | 10, 482, 51 |
| rung-9 B, Route 2 (Wartortle 9/70, 1) | a69a258 | 1 | 32 / 1, at full HP on the first frame | 0 | 1 | `NEXT` | 9, 300, 46 |
| | branch | 1 | 32 / 1, the same throw | 0 | 1 | 28.1 brain s, A 55, B 52, longest 1, name empty, ended by the fly (ED) | 9, 236, 43 |
| rung-9 C, the forest (`FLY_CATCH_CHECKPOINT`, Wartortle 18/70, 1) | both, identical | 1 | 32 / 1, at full HP, missed | 0 | 0 | -- | 9, 278, 18 |
| rung-9 D, the forest (the no-PP state, Bulbasaur 6/34, 1) | both, identical | 2 | 282 / 0 | 0 (never low with the ball dealt) | 0 | -- | 9, 285, 21 |
- **Throws and catches.** Three balls thrown in four runs on the branch, two catches; on a69a258
two thrown and one catch. The one run where they differ is the one whose wild HP passed a third
with the ball dealt: the fly threw from the throw's pad at once and caught. Two of the throws
were the fly's own choice from the ordinary pad on a battle's first frame, on both arms.
- **Names.** Both keyboards were ended by the fly's own A on ED, in 17 and 28 brain seconds, well
inside the bound. The brain's A and B fire at nearly the same rate there, so each letter it typed
it deleted again and both names came out empty, which the cartridge turns into the species'
name. That is the fly's spelling, kept as it is.
- **Stalls.** None from this row. Every run ends its battles; no keyboard reached the bound. The
flagged windows are `NEXT` runs through battle text on both arms (and on the branch's rung-9 A run
five `GO ROUTE, GO HEAL` windows, row 62's tug, 65h). The branch's rung-9 B run covers fewer tiles
after the keyboard because its frames after the catch differ from a69a258's (the keyboard took
28 brain seconds instead of `NEXT`'s few), not because anything waited: 635 macros started, 633
done, one refusal and one timeout, against 803, 802, one and one.