From e170812e7ce85c1b8b6108d565be6af58523ac15 Mon Sep 17 00:00:00 2001 From: acamilo Date: Thu, 24 Sep 2026 04:49:40 +0000 Subject: [PATCH] palette: a battle menu the cartridge still holds an A on deals no pad RUN's A is taken and the menu's box stays up while the game stops asking the joypad; a macro dealt on those frames pressed at a menu already gone and held the pad for its cursor wait. Empty until the cartridge asks again, 12.13's reading. --- .../flybrain-gb/src/pokemon_red/macros/palette.rs | 10 ++++++++++ .../flybrain-gb/src/pokemon_red/macros/tests.rs | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/services/flysim/crates/flybrain-gb/src/pokemon_red/macros/palette.rs b/services/flysim/crates/flybrain-gb/src/pokemon_red/macros/palette.rs index cfa53f0..e956259 100644 --- a/services/flysim/crates/flybrain-gb/src/pokemon_red/macros/palette.rs +++ b/services/flysim/crates/flybrain-gb/src/pokemon_red/macros/palette.rs @@ -547,6 +547,16 @@ pub fn scene_set(scene: Scene, state: &mut dyn MacroState) -> Vec { // list* closed it again; neither spent a turn, and the two of them were half the pad // between them. Two buttons that undo each other with nothing else changing are section // 12.2's trap spread over two sub-states of one turn. + // **A battle menu the cartridge is still holding an A on is not the fly's to answer** + // (row 63). The A that chose RUN, FIGHT or the Potion is taken, and the game stops asking + // the joypad while it acts on it -- so `hJoyLast` keeps that A, and the menu's box and + // cursor bytes stay on screen for as many as sixteen frames after its answer. A macro dealt + // there presses at a menu that is already gone: measured from the row-63 checkpoint, every + // `RUN` from FIGHT's column was followed by a `MOVE 4` dealt on the frame after, which + // pressed UP at "Got away safely!" and held the pad for its whole cursor wait. The pad is + // empty for those frames, which is 12.13's reading: the cartridge is driving, and it gives + // the buttons back on the first frame it asks again. + Scene::Battle { own_turn: true, .. } if state.a_latched() => Vec::new(), Scene::Battle { own_turn: true, .. } => match battle_menu(state) { // The move list. `BACK` is a button here because there is a list to leave (12.9) -- // but only while the moves can be *read*: a battler the seam cannot place leaves all diff --git a/services/flysim/crates/flybrain-gb/src/pokemon_red/macros/tests.rs b/services/flysim/crates/flybrain-gb/src/pokemon_red/macros/tests.rs index 68520ac..6e02400 100644 --- a/services/flysim/crates/flybrain-gb/src/pokemon_red/macros/tests.rs +++ b/services/flysim/crates/flybrain-gb/src/pokemon_red/macros/tests.rs @@ -2409,6 +2409,20 @@ fn move_one_is_not_fights_backstop_beside_a_usable_move() { assert_eq!(moves, ["MOVE 1", "MOVE 2"]); } +#[test] +fn a_battle_menu_the_cartridge_still_holds_an_a_on_deals_no_pad() { + // Row 63: RUN's A is taken, and the menu's box stays up while the game stops asking the + // joypad. The frame after `RUN` finished dealt `MOVE 4` over that box, which pressed at "Got + // away safely!" and held the pad through its whole cursor wait. Until the cartridge asks + // again the menu is not the fly's to answer. + let mut world = World::battle(); + assert!(!pad_of(&mut world).is_empty()); + world.latched_until = world.frames + 10; + assert_eq!(pad_of(&mut world), Vec::<&str>::new(), "the cartridge is acting on its last A"); + world.frames += 10; + assert!(pad_of(&mut world).contains(&"MOVE 1"), "and the pad is back when it asks again"); +} + #[test] fn buy_potion_takes_buy_then_the_item_then_confirms_twice() { let mut world = World::room();