macros: the mart's list cursor is the entry too; the catch test pins its first-window ball (row 71)
state::shop reports the buy and sell lists' cursor as row plus wListScrollOffset, only while the list is on screen. MART_CURSOR_ROWS stays. The catch ROM test now asserts its ball sits in the bag window's first rows, so it covers the unscrolled throw beside row 71's scrolled one.
This commit is contained in:
parent
2dcce9452a
commit
a6632b4acf
6 changed files with 58 additions and 14 deletions
|
|
@ -1072,6 +1072,8 @@ the cartridge instead.
|
||||||
|
|
||||||
**`BattleMenu::Bag`'s `cursor`** is now `wCurrentMenuItem + wListScrollOffset`, the bag entry
|
**`BattleMenu::Bag`'s `cursor`** is now `wCurrentMenuItem + wListScrollOffset`, the bag entry
|
||||||
under the arrow, which is the sum the cartridge makes on A. In the live trap the arrow was on row 1
|
under the arrow, which is the sum the cartridge makes on A. In the live trap the arrow was on row 1
|
||||||
with an offset of 3, so it was on entry 4, the Poké Ball. The mart's buy list
|
with an offset of 3, so it was on entry 4, the Poké Ball. `state::shop`'s buy and sell lists
|
||||||
(`MART_CURSOR_ROWS`, section 7) still uses the first three rows only.
|
report their cursor (and its `max`) as the entry the same way. The offset is added only while a
|
||||||
|
list is on screen, because the byte outlives every list. Purchases still use only the first three
|
||||||
|
rows (`MART_CURSOR_ROWS`, section 7).
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2142,11 +2142,16 @@ restored the same battle with the same bag open, so the trap came straight back.
|
||||||
the moves, `SWITCH`, `RUN` and the bag's `BACK` at low HP, so the dead button became the only
|
the moves, `SWITCH`, `RUN` and the bag's `BACK` at low HP, so the dead button became the only
|
||||||
one.
|
one.
|
||||||
|
|
||||||
The mart's buy list scrolls the same way, and `MART_CURSOR_ROWS` (row 55) still limits purchases
|
Other lists, checked: the mart's buy and sell lists are `DisplayListMenuID` lists too, and
|
||||||
to the first three rows. Lifting that limit with the pinned offset is a separate change.
|
`state::shop` now reports their cursor as the entry in the same way. The battle menu, the move
|
||||||
|
list, the party list and the start menu do not scroll. No macro navigates the PC's lists.
|
||||||
|
`MART_CURSOR_ROWS` (row 55) still limits purchases to the first three rows, because lifting it puts
|
||||||
|
new buttons on the pad and needs its own survey on the cartridge.
|
||||||
|
|
||||||
Tests: `a_battle_frame_with_a_cursor_accepting_input_is_the_flys_turn` (state, a bag scrolled by
|
Tests: `a_battle_frame_with_a_cursor_accepting_input_is_the_flys_turn` (state, a bag scrolled by
|
||||||
three),
|
three), `a_mart_reports_which_of_its_screens_is_up` (a scrolled buy list, and a stale offset on the
|
||||||
|
counter menu), the catch test's check that its ball is in the window's first rows (it still
|
||||||
|
throws),
|
||||||
`row71_a_ball_past_the_bags_window_is_thrown` (`FLY_ROW71_CHECKPOINT`, the live trap) and
|
`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).
|
`row71_the_list_scroll_offset_is_where_the_cartridge_reads_it` (FLY_ROM).
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,11 @@ pub const CHEAPEST_PURCHASE: u32 = {
|
||||||
/// can name, and a purchase aimed at one is a button whose script gives up before it presses
|
/// can name, and a purchase aimed at one is a button whose script gives up before it presses
|
||||||
/// anything. [`super::palette::stock_index`] is where the rule is applied, once, for both the pad
|
/// anything. [`super::palette::stock_index`] is where the rule is applied, once, for both the pad
|
||||||
/// and the plan.
|
/// and the plan.
|
||||||
|
///
|
||||||
|
/// Row 71 pinned `wListScrollOffset` from the cartridge, and `state::shop` now reports the buy
|
||||||
|
/// list's cursor as the entry (row plus offset), so the reading is right however the list is
|
||||||
|
/// scrolled. The limit stays until a purchase past the third row has been surveyed on the
|
||||||
|
/// cartridge: lifting it would put new buttons on the pad, which is its own change.
|
||||||
pub const MART_CURSOR_ROWS: usize = 3;
|
pub const MART_CURSOR_ROWS: usize = 3;
|
||||||
|
|
||||||
/// Cursor indices of the battle menu, as `state::BattleMenu::Main` documents them: "0 FIGHT,
|
/// Cursor indices of the battle menu, as `state::BattleMenu::Main` documents them: "0 FIGHT,
|
||||||
|
|
|
||||||
|
|
@ -1370,19 +1370,33 @@ pub fn shop(memory: &mut dyn MemoryReader) -> Option<Shop> {
|
||||||
if text_box(memory).waiting {
|
if text_box(memory).waiting {
|
||||||
return Some(Shop { screen: ShopScreen::Talking, cursor });
|
return Some(Shop { screen: ShopScreen::Talking, cursor });
|
||||||
}
|
}
|
||||||
let screen = if mart_item_window_drawn(memory) {
|
if mart_item_window_drawn(memory) {
|
||||||
ShopScreen::Buying
|
return Some(Shop { screen: ShopScreen::Buying, cursor: list_entry(memory, cursor) });
|
||||||
} else {
|
}
|
||||||
ShopScreen::BuySellQuit
|
return Some(Shop { screen: ShopScreen::BuySellQuit, cursor });
|
||||||
};
|
|
||||||
return Some(Shop { screen, cursor });
|
|
||||||
}
|
}
|
||||||
if read(memory, ram::wTextBoxID) != poke::BUY_SELL_QUIT_MENU {
|
if read(memory, ram::wTextBoxID) != poke::BUY_SELL_QUIT_MENU {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let screen =
|
if list == poke::ITEM_LIST_MENU {
|
||||||
if list == poke::ITEM_LIST_MENU { ShopScreen::Selling } else { ShopScreen::BuySellQuit };
|
return Some(Shop { screen: ShopScreen::Selling, cursor: list_entry(memory, cursor) });
|
||||||
Some(Shop { screen, cursor })
|
}
|
||||||
|
Some(Shop { screen: ShopScreen::BuySellQuit, cursor })
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A `DisplayListMenuID` cursor as the entry it is on rather than the window's row (row 71).
|
||||||
|
///
|
||||||
|
/// The arrow walks the window's rows and the list scrolls under it, so the entry is the row plus
|
||||||
|
/// [`poke::LIST_SCROLL_OFFSET`], and the last entry the window can reach is its last row plus the
|
||||||
|
/// same. Only for a list that is on screen: the offset is one shared byte that outlives every list,
|
||||||
|
/// so a menu that is not a list menu keeps its own cursor.
|
||||||
|
fn list_entry(memory: &mut dyn MemoryReader, cursor: Cursor) -> Cursor {
|
||||||
|
let offset = read(memory, poke::LIST_SCROLL_OFFSET);
|
||||||
|
Cursor {
|
||||||
|
current: cursor.current.saturating_add(offset),
|
||||||
|
max: cursor.max.saturating_add(offset),
|
||||||
|
..cursor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the mart's priced item window is the thing drawn over the counter menu.
|
/// Whether the mart's priced item window is the thing drawn over the counter menu.
|
||||||
|
|
|
||||||
|
|
@ -586,6 +586,17 @@ fn a_mart_reports_which_of_its_screens_is_up() {
|
||||||
.screen_tile(poke::MART_NAME_COLUMN, poke::MART_NAME_ROW, poke::CHAR_UPPER_A);
|
.screen_tile(poke::MART_NAME_COLUMN, poke::MART_NAME_ROW, poke::CHAR_UPPER_A);
|
||||||
assert_eq!(shop(&mut wram).map(|shop| shop.screen), Some(ShopScreen::Buying));
|
assert_eq!(shop(&mut wram).map(|shop| shop.screen), Some(ShopScreen::Buying));
|
||||||
|
|
||||||
|
// Row 71: the buy list's cursor is the entry, the window's row plus the scroll offset, and so
|
||||||
|
// is the last entry the window reaches.
|
||||||
|
wram.cursor(4, 5, 1, 2, poke::pad::A | poke::pad::B).set(poke::LIST_SCROLL_OFFSET, 2);
|
||||||
|
let buying = shop(&mut wram).unwrap();
|
||||||
|
assert_eq!((buying.cursor.current, buying.cursor.max), (3, 4));
|
||||||
|
// The counter menu is not a list menu: a stale offset leaves its cursor alone.
|
||||||
|
wram.screen_tile(poke::MART_NAME_COLUMN, poke::MART_NAME_ROW, 0x7f);
|
||||||
|
let counter = shop(&mut wram).unwrap();
|
||||||
|
assert_eq!(counter.screen, ShopScreen::BuySellQuit);
|
||||||
|
assert_eq!((counter.cursor.current, counter.cursor.max), (1, 2));
|
||||||
|
|
||||||
// The bag list on its own is the start menu's, not a mart's.
|
// The bag list on its own is the start menu's, not a mart's.
|
||||||
let mut wram = Wram::overworld();
|
let mut wram = Wram::overworld();
|
||||||
wram.set(ram::wFontLoaded, poke::BIT_FONT_LOADED)
|
wram.set(ram::wFontLoaded, poke::BIT_FONT_LOADED)
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,13 @@ fn a_catch_on_the_cartridge_pays_the_catch_rule_once_with_the_species_in_its_lab
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
eprintln!("bag holds {balls} balls");
|
eprintln!("bag holds {balls} balls");
|
||||||
|
// Row 71's other half: this checkpoint's ball is in the bag window's first rows, unscrolled,
|
||||||
|
// so the catch below is the throw that worked before the scroll offset was read and must
|
||||||
|
// still work after it.
|
||||||
|
let ball_entry = state::bag(&mut Run::resume(&rom, &checkpoint).gb)
|
||||||
|
.iter()
|
||||||
|
.position(|item| (0x01..=0x04).contains(&item.id) && item.count > 0);
|
||||||
|
assert!(ball_entry.is_some_and(|entry| entry < 3), "ball at bag entry {ball_entry:?}");
|
||||||
|
|
||||||
// Five brain minutes per attempt is generous for a forest checkpoint: the live run threw 28
|
// Five brain minutes per attempt is generous for a forest checkpoint: the live run threw 28
|
||||||
// balls in its first Viridian Forest session (`pokemon_red::macros::palette`). An attempt
|
// balls in its first Viridian Forest session (`pokemon_red::macros::palette`). An attempt
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue