diff --git a/services/flysim/crates/flysim/examples/trap_hunt.rs b/services/flysim/crates/flysim/examples/trap_hunt.rs index 7c5947e..8543fda 100644 --- a/services/flysim/crates/flysim/examples/trap_hunt.rs +++ b/services/flysim/crates/flysim/examples/trap_hunt.rs @@ -236,6 +236,37 @@ struct Trace { move_starts: (u64, u64), wall_seconds: f64, row66: Row66, + row69: Row69, +} + +/// Row 69's tally: frames the throw's pad was up, and every naming screen -- how long, the fly's +/// own presses on it, the name, and what ended it. +#[derive(Default)] +struct Row69 { + throw_pad_frames: u64, + keyboard_frames: u64, + keyboard_presses: u64, + /// The keyboard up now: brain ms it opened, frames, presses, longest, name, CONFIRM started. + open: Option<(f64, u64, u64, u8, String, bool)>, + keyboards: Vec, + previous_mask: u32, + /// A, B and START going down on the keyboard, over the run. + keys: BTreeMap<&'static str, u64>, +} + +/// `wStringBuffer` (`CalcStringLength`'s operand on the cartridge), in Red's charmap. +fn row69_name(gb: &mut flybrain_gb::Emulator) -> String { + use flybrain_gb::MemoryReader; + (0..11u16) + .map(|index| gb.read8(0xcf4b + index)) + .take_while(|byte| *byte != 0x50) + .map(|byte| match byte { + 0x80..=0x99 => char::from(b'A' + (byte - 0x80)), + 0xa0..=0xb9 => char::from(b'a' + (byte - 0xa0)), + 0x7f => ' ', + _ => '?', + }) + .collect() } /// Row 66's shop/ball/catch tally: pad frames, starts and outcomes of the watched buttons, and @@ -367,6 +398,9 @@ impl FrameObserver for Hunt { && layer.running().is_none() { let names: Vec = layer.feed_palette().into_iter().map(|slot| slot.name).collect(); + if names == ["THROW BALL"] || names == ["ITEM", "THROW BALL"] { + self.trace.row69.throw_pad_frames += 1; + } if !names.is_empty() { let row = &mut self.trace.row66; row.free_frames += 1; @@ -390,6 +424,51 @@ impl FrameObserver for Hunt { let ms = parts.agent.network.ms; let location = frame.location; let trace = &mut self.trace; + { + let naming = flybrain_gb::pokemon_red::state::naming_screen(parts.emulator); + let row = &mut trace.row69; + match (naming, row.open.take()) { + (Some(naming), open) => { + let (since, frames, presses, longest, _, confirm) = + open.unwrap_or((ms, 0, 0, 0, String::new(), false)); + // A press is a button going down while no macro runs: each of the eight bits + // on its own edge, since the D-pad group is almost always holding one. + let press = if executed.events.is_empty() { + (executed.mask & !row.previous_mask).count_ones() + } else { + 0 + }; + let letters = executed.mask & !row.previous_mask; + for (bit, name) in [(0x10u32, "A"), (0x20, "B"), (0x40, "START")] { + if executed.events.is_empty() && letters & bit != 0 { + *row.keys.entry(name).or_default() += 1; + } + } + let confirm = confirm || executed.events.iter().any(|event| event.name == "CONFIRM"); + row.keyboard_frames += 1; + row.keyboard_presses += u64::from(press); + row.open = Some(( + since, + frames + 1, + presses + u64::from(press), + longest.max(naming.length), + row69_name(parts.emulator), + confirm, + )); + } + (None, Some((since, frames, presses, longest, name, confirm))) => { + row.keyboards.push(format!( + "{:.2} min: {frames} frames ({:.1} brain s), {presses} presses, longest {longest}, \ + name {name:?}, ended by {}", + (since - trace.began_ms) / MINUTE_MS, + (ms - since) / 1000.0, + if confirm { "CONFIRM (the bound)" } else { "the fly (ED or START)" } + )); + } + (None, None) => {} + } + row.previous_mask = executed.mask; + } for event in &executed.events { if std::env::var("FLY_TRAP_LOG_MACROS").is_ok_and(|value| value == "1") { let pad: Vec = parts.macros.as_deref().map(|layer| layer.feed_palette().into_iter().map(|slot| slot.name).collect()).unwrap_or_default(); @@ -626,6 +705,7 @@ fn run( move_starts: (0, 0), wall_seconds: 0.0, row66: Row66::default(), + row69: Row69::default(), seeded: seeded_note, refusals: BTreeMap::new(), refusal_run: (None, 0), @@ -1100,6 +1180,25 @@ fn main() { if let Some(last) = row.last { println!("- end: balls {} money {} party+box {} owned {} map {:#04x}", last.0, last.1, last.2, last.3, last.4); } for line in row.log.iter().take(150) { println!("- {line}"); } } + { + let row = &trace.row69; + println!( + "\n## Row 69: the throw's pad and the keyboard\n\n- free frames with the throw's pad \ + (THROW BALL alone, or with ITEM): {}\n- keyboard frames {}, the fly's own button presses \ + on it {} (of them {:?})", + row.throw_pad_frames, row.keyboard_frames, row.keyboard_presses, row.keys + ); + for line in &row.keyboards { + println!("- keyboard at {line}"); + } + if let Some((since, frames, presses, longest, name, _)) = &row.open { + println!( + "- keyboard still up at the end: opened {:.2} min, {frames} frames, {presses} presses, \ + longest {longest}, name {name:?}", + (since - trace.began_ms) / MINUTE_MS + ); + } + } for (rank, label, ms) in &trace.rungs { println!("- rung {rank} {label} at {:.2} brain minutes", ms / MINUTE_MS); } diff --git a/services/flysim/crates/flysim/tests/rom_catch.rs b/services/flysim/crates/flysim/tests/rom_catch.rs index 5f6feea..80303a2 100644 --- a/services/flysim/crates/flysim/tests/rom_catch.rs +++ b/services/flysim/crates/flysim/tests/rom_catch.rs @@ -33,6 +33,7 @@ //! different test's question; this one says out loud that it skipped. use flybrain_core::decoder::PopulationDecoder; +use flybrain_core::decoder::gameboy::to_button_mask; use flybrain_core::decoder::gameboy::gameboy_decoder_config_with_macros; use flybrain_core::ordered::NumberMap; use flybrain_gb::adapter::RewardEvent; @@ -295,6 +296,59 @@ struct AfterCatch { ball_dealt: u32, /// Every pad the fly could decide on in that stretch. pads: std::collections::BTreeSet>, + /// Row 69: the naming screen, as this test reads it off the cartridge ([`keyboard`]). + keyboard: Keyboard, +} + +/// Row 69: what the naming screen saw, read by this test itself rather than by the palette. +#[derive(Debug, Default)] +struct Keyboard { + /// Frames the keyboard was up. + frames: u32, + /// Frames on it with no macro running on which the cartridge was given a button: the fly's + /// own presses. + raw_frames: u32, + /// Macros started while it was up, by name. + starts: Vec<&'static str>, + /// Pads dealt on it, while nothing ran. + pads: std::collections::BTreeSet>, + /// The longest the name got, and the name on its last frame (`wStringBuffer`, decoded). + longest: u8, + name: String, + /// Frames from its first frame to its last. + span: u32, + closed: bool, +} + +/// `wStringBuffer`, from `CalcStringLength`'s `ld hl, wStringBuffer` on the cartridge (row 69). +const STRING_BUFFER: u16 = 0xcf4b; +/// `wNamingScreenNameLength` (row 69, `pokemon_red::state::poke::NAMING_LENGTH`). +const NAMING_LENGTH: u16 = 0xcee9; + +/// The naming screen, as this test reads it: the keyboard's menu bytes, its box's corner at +/// (0, 4), and an underscore under the name at (10, 3). The letters typed, or `None`. +fn keyboard(run: &mut Run) -> Option { + let tile = |run: &mut Run, x: u16, y: u16| run.byte(ram::wTileMap + y * 20 + x); + let menu = run.byte(ram::wTopMenuItemY) == 3 + && run.byte(ram::wMaxMenuItem) == 7 + && run.byte(ram::wMenuWatchedKeys) == 0xff; + (menu && tile(run, 0, 4) == 0x79 && tile(run, 19, 14) == 0x7e + && matches!(tile(run, 10, 3), 0x76 | 0x77)) + .then(|| run.byte(NAMING_LENGTH)) +} + +/// The name in `wStringBuffer`, in Red's charmap: capitals from `$80`, small letters from `$a0`. +fn typed(run: &mut Run) -> String { + (0..11u16) + .map(|index| run.byte(STRING_BUFFER + index)) + .take_while(|byte| *byte != 0x50) + .map(|byte| match byte { + 0x80..=0x99 => char::from(b'A' + (byte - 0x80)), + 0xa0..=0xb9 => char::from(b'a' + (byte - 0xa0)), + 0x7f => ' ', + _ => '?', + }) + .collect() } /// One drive: `idle` frames with nothing pressed first (so each attempt reaches the wild battle @@ -302,6 +356,17 @@ struct AfterCatch { /// drive up to the catch, then the pad's own buttons in turn. `None` when no ball kept anything /// within the budget: one ball in the bag misses about two throws in three. fn drive_past_a_catch(rom: &[u8], checkpoint: &flysim::store::Checkpoint, idle: u32) -> Option { + drive_past_a_catch_typing(rom, checkpoint, idle, true) +} + +/// [`drive_past_a_catch`], and on the keyboard lean on A and B (`type_keys`) or on nothing, so +/// only the D-pad group's own rotation reaches it and the row 69 bound is what ends it. +fn drive_past_a_catch_typing( + rom: &[u8], + checkpoint: &flysim::store::Checkpoint, + idle: u32, + type_keys: bool, +) -> Option { let mut run = Run::resume(rom, checkpoint); for _ in 0..idle { run.ms += MS_PER_FRAME; @@ -317,9 +382,22 @@ fn drive_past_a_catch(rom: &[u8], checkpoint: &flysim::store::Checkpoint, idle: let mut ball_dealt = 0u32; let mut pads = std::collections::BTreeSet::new(); let mut hold = 0usize; + let mut board = Keyboard::default(); + let mut board_from: Option = None; for frame in 0..budget { let bound = run.layer.bound_channels(); - let hot = if caught_at.is_none() { + let on_keyboard = keyboard(&mut run); + let hot = if caught_at.is_some() && on_keyboard.is_some() && bound.is_empty() && !type_keys { + None + } else if caught_at.is_some() && on_keyboard.is_some() && bound.is_empty() { + // Row 69: the keyboard's pad is the fly's own buttons. The stub leans on A (a letter) + // mostly and on B (a deletion) now and then; the D-pad is the direction group's own + // rotation. What the name comes out as is the stub's, as it will be the brain's. + if frame % BURST_FRAMES == 0 { + hold += 1; + } + Some(if hold % 4 == 3 { "command_5".to_string() } else { "command_4".to_string() }) + } else if caught_at.is_none() { if run.in_wild_battle() { Some(BALL.to_string()) } else { @@ -343,7 +421,34 @@ fn drive_past_a_catch(rom: &[u8], checkpoint: &flysim::store::Checkpoint, idle: } } let active = run.decoder.decode_bound(&rates(hot.as_deref()), run.ms, false, None, Some(&bound)); - run.legacy.execute(Some(&mut run.layer), &active, 0, run.ms, &mut run.gb, &run.adapter); + // The readout's own buttons as raw mode would press them: the layer passes them to the + // cartridge only where a scene says so (the title, and since row 69 the keyboard). + let raw = to_button_mask(&active); + let idle = run.layer.running().is_none(); + let executed = + run.legacy.execute(Some(&mut run.layer), &active, raw, run.ms, &mut run.gb, &run.adapter); + if let Some(length) = on_keyboard { + board.frames += 1; + board_from.get_or_insert(frame); + board.span = frame - board_from.unwrap_or(frame); + board.longest = board.longest.max(length); + board.name = typed(&mut run); + if idle { + if !bound.is_empty() { + board.pads.insert(bound.clone()); + } + if executed.mask != 0 && executed.events.is_empty() { + board.raw_frames += 1; + } + } + for event in &executed.events { + if event.outcome.is_none() { + board.starts.push(event.name); + } + } + } else if board.frames > 0 { + board.closed = true; + } run.ms += MS_PER_FRAME; run.frame += 1; let evaluated = run @@ -358,7 +463,7 @@ fn drive_past_a_catch(rom: &[u8], checkpoint: &flysim::store::Checkpoint, idle: && run.byte(ram::wIsInBattle) == 0 { assert!(!run.catches().is_empty(), "the catch pays at the battle's end"); - return Some(AfterCatch { caught_at, ended_at: frame, ball_dealt, pads }); + return Some(AfterCatch { caught_at, ended_at: frame, ball_dealt, pads, keyboard: board }); } } assert!(caught_at.is_none(), "a battle still running {budget} frames after its catch"); @@ -419,3 +524,286 @@ fn row66_after_a_catch_the_pad_is_not_the_bag_and_the_battle_ends() { after.ended_at - after.caught_at ); } + +/// Row 69 ("let the fly name it"): after a catch the nickname offer is answered YES as before, +/// and the keyboard's pad is the fly's own buttons -- the D-pad, A, B, START -- with no macro on +/// it, until the name is full (or the bound runs), when `CONFIRM` alone hands the name back. The +/// keyboard closes and the battle ends. +/// +/// On a69a258 (row 66) the keyboard read as the battle's between-turns frame and its pad was +/// `NEXT`, whose A presses typed the name. +#[test] +fn row69_after_a_catch_the_keyboard_is_the_flys_own_buttons_and_it_ends() { + let Some(rom) = rom() else { + eprintln!("skipped: FLY_ROM is not set"); + return; + }; + let Some(checkpoint) = checkpoint() else { + eprintln!("skipped: no FLY_CATCH_CHECKPOINT"); + return; + }; + if Run::resume(&rom, &checkpoint).balls() == 0 { + eprintln!("skipped: the checkpoint's bag holds no ball"); + return; + } + let after = (0..24) + .find_map(|attempt| drive_past_a_catch(&rom, &checkpoint, attempt * 5)) + .expect("one of 24 attempts should keep a Pokémon"); + let board = &after.keyboard; + eprintln!( + "caught at f{}, battle over at f{}; keyboard {} frames over {} (raw {}), longest {}, \ + name {:?}, starts {:?}, pads {:?}, closed {}", + after.caught_at, + after.ended_at, + board.frames, + board.span, + board.raw_frames, + board.longest, + board.name, + board.starts, + board.pads, + board.closed + ); + assert!(board.frames > 0, "a catch goes to the keyboard (the nickname offer answered YES)"); + assert!(board.raw_frames > 0, "the fly's own buttons reached the keyboard"); + assert!(board.longest > 0, "the fly typed a letter"); + assert!( + board.starts.iter().all(|name| *name == "CONFIRM"), + "no macro types on the keyboard: {:?}", + board.starts + ); + assert!( + board.pads.iter().all(|pad| pad == &vec!["macro_confirm".to_string()]), + "the keyboard deals CONFIRM alone or nothing: {:?}", + board.pads + ); + assert_ne!(board.name, "AAAAAAAAAA", "not the name NEXT's A presses typed on a69a258"); + assert!(board.closed, "the keyboard closed"); + // The bound is sixty brain seconds, about 3,600 frames; the stub fills the name long before. + assert!(board.span < 3_700, "the keyboard was up for {} frames", board.span); + assert!(after.ended_at - after.caught_at < 6_000, "the battle ended"); +} + +/// `ItemUseBall`'s HP test, this file's own reading of it (`engine/items/item_effects.asm`): for +/// the first ball in the bag, `(MaxHP * 255 / BallFactor) / max(HP / 4, 1) >= 255`, a factor of 8 +/// for a Great Ball and 12 for the rest. +fn enemy_low(run: &mut Run) -> bool { + let word = |run: &mut Run, address: u16| { + u16::from(run.byte(address)) * 256 + u16::from(run.byte(address + 1)) + }; + let hp = word(run, ram::wEnemyMonHP); + let max = word(run, ram::wEnemyMonMaxHP); + let Some(ball) = state::bag(&mut run.gb) + .iter() + .find(|item| (0x01..=0x04).contains(&item.id) && item.count > 0) + .map(|item| item.id) + else { + return false; + }; + if hp == 0 || max == 0 || hp > max { + return false; + } + let factor: u32 = if ball == 0x03 { 8 } else { 12 }; + let quarter = u32::from((hp >> 2) as u8).max(1); + (u32::from(max) * 255 / factor) / quarter >= 255 +} + +/// Row 69's checkpoint for the low-HP drive, or the catch checkpoint when it is not set. +/// +/// The catch checkpoint's lead is a level-twenty Wartortle that takes every forest Pokémon from +/// full HP to nothing in one hit, so no wild Pokémon is ever *low* there. `FLY_ROW69_CHECKPOINT` +/// names a rung-9 state whose lead is weak enough for a wild Pokémon's HP to pass through a third +/// on its way down, with a ball in the bag. +fn row69_checkpoint() -> Option { + let path = std::env::var_os("FLY_ROW69_CHECKPOINT")?; + Some( + flysim::store::load(std::path::Path::new(&path)) + .expect("the checkpoint should be a FLYSIM01 envelope"), + ) +} + +/// Row 69 ("throw on low HP only"): in a wild battle, with a ball in the bag and the wild +/// Pokémon's HP where the ball's HP factor is at its best, `THROW BALL` is the only attack-side +/// button on the pad -- no `MOVE n`, no `SWITCH`, no `RUN` -- and the throw happens. +/// +/// The stub leans on the pad's own buttons in turn, leaving `THROW BALL` alone while HP is high +/// so the checkpoint's one ball is not spent before the HP is low. On a69a258 the low-HP pads +/// hold the moves beside the ball. +#[test] +fn row69_at_low_hp_a_wild_battles_pad_is_the_ball() { + let Some(rom) = rom() else { + eprintln!("skipped: FLY_ROM is not set"); + return; + }; + let Some(checkpoint) = row69_checkpoint() else { + eprintln!("skipped: no FLY_ROW69_CHECKPOINT"); + return; + }; + if Run::resume(&rom, &checkpoint).balls() == 0 { + eprintln!("skipped: the checkpoint's bag holds no ball"); + return; + } + let mut low_pads: std::collections::BTreeSet> = Default::default(); + let mut high_ball_pads: std::collections::BTreeSet> = Default::default(); + let mut low_frames = 0u32; + let mut thrown_low = 0u32; + let mut battles = 0u32; + let mut hp_log: Vec<(u8, u16, u16, u16)> = Vec::new(); + for attempt in 0..16u32 { + let mut run = Run::resume(&rom, &checkpoint); + for _ in 0..attempt * 7 { + run.ms += MS_PER_FRAME; + run.frame += 1; + let _ = run + .legacy + .stub_advance(Some(&mut run.layer), &mut run.gb, &mut run.adapter, run.ms) + .expect("a frame should complete"); + } + let mut hold = 0usize; + let mut was_wild = false; + for frame in 0..3 * 60 * 60u32 { + let bound = run.layer.bound_channels(); + let wild = run.in_wild_battle(); + if wild && !was_wild { + battles += 1; + } + was_wild = wild; + let low = wild && enemy_low(&mut run); + if wild { + let hp = u16::from(run.byte(ram::wEnemyMonHP)) * 256 + + u16::from(run.byte(ram::wEnemyMonHP + 1)); + let max = u16::from(run.byte(ram::wEnemyMonMaxHP)) * 256 + + u16::from(run.byte(ram::wEnemyMonMaxHP + 1)); + let own = u16::from(run.byte(ram::wBattleMonHP)) * 256 + + u16::from(run.byte(ram::wBattleMonHP + 1)); + let seen = (run.byte(ram::wEnemyMonSpecies), hp, max, own); + if hp_log.last() != Some(&seen) { + hp_log.push(seen); + } + } + let idle = run.layer.running().is_none(); + if idle && wild && bound.iter().any(|channel| channel == THROW_BALL_CHANNEL) { + if low { + low_frames += 1; + low_pads.insert(bound.clone()); + } else { + high_ball_pads.insert(bound.clone()); + } + } + let hot = if wild && !bound.is_empty() { + if frame % BURST_FRAMES == 0 { + hold += 1; + } + // Not `RUN` either: a fled battle never reaches low HP. + let choices: Vec<&String> = bound + .iter() + .filter(|channel| low || *channel != THROW_BALL_CHANNEL) + .filter(|channel| *channel != "macro_run") + .collect(); + choices.get(hold % choices.len().max(1)).map(|channel| channel.to_string()) + } else { + let slot = (run.frame / BURST_FRAMES) as usize % run.channels.len(); + Some(run.channels[slot].to_string()) + }; + let balls = run.balls(); + let active = + run.decoder.decode_bound(&rates(hot.as_deref()), run.ms, false, None, Some(&bound)); + run.legacy.execute(Some(&mut run.layer), &active, 0, run.ms, &mut run.gb, &run.adapter); + run.ms += MS_PER_FRAME; + run.frame += 1; + let evaluated = run + .legacy + .stub_advance(Some(&mut run.layer), &mut run.gb, &mut run.adapter, run.ms) + .expect("a frame should complete"); + run.payouts.extend(evaluated.rewards); + if run.balls() < balls { + if low { + thrown_low += 1; + } + break; + } + } + if thrown_low > 0 && low_frames > 0 { + break; + } + } + eprintln!( + "{battles} wild battles; {low_frames} low-HP frames with the ball dealt; thrown at low HP \ + {thrown_low}; low pads {low_pads:?}; high pads with the ball {high_ball_pads:?}" + ); + eprintln!("(species, enemy hp, max, own hp) as it changed: {:?}", &hp_log[..hp_log.len().min(120)]); + assert!(low_frames > 0, "no wild battle reached low HP with a ball dealt"); + let allowed = [THROW_BALL_CHANNEL, "macro_item"]; + for pad in &low_pads { + assert!( + pad.iter().all(|channel| allowed.contains(&channel.as_str())), + "a low-HP pad with more than the ball on its attack side: {pad:?}" + ); + } + assert!(thrown_low > 0, "the ball was thrown at low HP"); +} + +/// Row 69's bound: a fly that types nothing is not left on the keyboard. After sixty brain seconds +/// (`palette::NAMING_BOUND_MS`) `CONFIRM` alone is dealt, hands the name back empty, and the +/// cartridge keeps the species' own name. The stub presses no letter: only the D-pad group's own +/// rotation reaches the keyboard. +#[test] +fn row69_a_fly_that_types_nothing_is_ended_by_the_bound() { + let Some(rom) = rom() else { + eprintln!("skipped: FLY_ROM is not set"); + return; + }; + let Some(checkpoint) = checkpoint() else { + eprintln!("skipped: no FLY_CATCH_CHECKPOINT"); + return; + }; + if Run::resume(&rom, &checkpoint).balls() == 0 { + eprintln!("skipped: the checkpoint's bag holds no ball"); + return; + } + let after = (0..24) + .find_map(|attempt| drive_past_a_catch_typing(&rom, &checkpoint, attempt * 5, false)) + .expect("one of 24 attempts should keep a Pokémon"); + let board = &after.keyboard; + eprintln!( + "keyboard {} frames over {} (raw {}), longest {}, name {:?}, starts {:?}, pads {:?}, \ + closed {}", + board.frames, + board.span, + board.raw_frames, + board.longest, + board.name, + board.starts, + board.pads, + board.closed + ); + assert_eq!(board.longest, 0, "nothing typed"); + assert_eq!(board.starts, vec!["CONFIRM"], "the bound's one button, once"); + assert_eq!( + board.pads.iter().cloned().collect::>(), + vec![vec!["macro_confirm".to_string()]] + ); + // Sixty brain seconds at 59.7275 frames a second is 3,584 frames, and a little for the press. + assert!((3_500..3_800).contains(&board.span), "the bound ran: {} frames", board.span); + assert!(board.closed); +} + +/// Row 69: the two naming-screen bytes the palette reads are where the cartridge's own +/// instructions store them. `PrintNicknameAndUnderscores`: `ld a, c / ld [wNamingScreenNameLength], +/// a / hlcoord 10, 2` (`$79 $EA lo hi $21 $D2 $C3`); `DisplayNamingScreen.pressedStart`: +/// `ld a, 1 / ld [wNamingScreenSubmitName], a / ret` (`$3E $01 $EA lo hi $C9`). +#[test] +fn row69_the_naming_bytes_are_where_the_cartridge_stores_them() { + let Some(rom) = rom() else { + eprintln!("skipped: FLY_ROM is not set"); + return; + }; + use flybrain_gb::pokemon_red::state::poke; + let [lo, hi] = poke::NAMING_LENGTH.to_le_bytes(); + let length = [0x79, 0xea, lo, hi, 0x21, 0xd2, 0xc3]; + assert!(rom.windows(length.len()).any(|window| window == length), "wNamingScreenNameLength"); + let [lo, hi] = poke::NAMING_SUBMIT.to_le_bytes(); + let submit = [0x3e, 0x01, 0xea, lo, hi, 0xc9]; + assert!(rom.windows(submit.len()).any(|window| window == submit), "wNamingScreenSubmitName"); + assert_eq!(poke::NAMING_SUBMIT, poke::NAMING_LENGTH + 1, "consecutive in the UNION"); +} diff --git a/services/flysim/crates/flysim/tests/rom_macros_mode.rs b/services/flysim/crates/flysim/tests/rom_macros_mode.rs index e53665c..93e7d56 100644 --- a/services/flysim/crates/flysim/tests/rom_macros_mode.rs +++ b/services/flysim/crates/flysim/tests/rom_macros_mode.rs @@ -1011,8 +1011,11 @@ impl Run { } } // Section 12.13's claim, per frame: an `Unknown` with nothing drawn deals nothing. + // The keyboard (row 69) is drawn -- its own box, not the text font -- and its bound's + // `CONFIRM` is a pad on something drawn, so it is not counted. if self.layer.scene_name() == "unknown" && !flybrain_gb::pokemon_red::state::text_box(&mut self.gb).open + && flybrain_gb::pokemon_red::state::naming_screen(&mut self.gb).is_none() && !self.layer.bound_channels().is_empty() { self.unknown_pads_with_no_box += 1;