Skip to content

AutoStory: shared launch from HOME to the overworld on a save - #477

Merged
dayfine merged 8 commits into
nav/sharedfrom
autostory/launch-from-home
Nov 14, 2026
Merged

dayfine merged 8 commits into
nav/sharedfrom
autostory/launch-from-home

Conversation

@dayfine

@dayfine dayfine commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Depends on #332

Base autostory/engine (#332); the diff shows only this change.

Each game gets from HOME to its overworld in its own way, and none of them is a story event of its own: tonight console B needed hand presses on HOME, and a PLZA run failed in 20 s because the game was not open (the shared preflight only refuses HOME). This adds one shared launch step to the engine, launch_story_game(backend, policy, request) in Engine/Pokemon_StoryLaunch.h: a per-game StoryLaunchPolicy says how its screens look, and one driver looks, does one thing, counts each screen's presses, and ends only on an overworld that holds for 3 looks. It confirms the game's HOME tile before any A, never presses on a new-game screen, and fails as launch_failed (no reload, no recovery) on a missing tile, a screen that ignores its press, or no overworld after max_looks. No game uses it yet; adoption is one PR per game. A prompt can move the cursor first (before: the update prompt's Up, Up), and a prompt or the title can be read only after the launch closed or launched the game (after_launch, title_after_launch) when its check would also match the game in play. Tested with Pokemon::StoryLaunch (16 cases on the scripted fake backend: closed on HOME, open on title, overworld kept and restarted, backup save, license check back to HOME, tile search, missing tile, stuck title, new game, black screen timeout, update prompt, loose title in front).

On a Switch, switch_home_tile_named(language, name) is the tile check: NintendoSwitch_HomeTileReader finds HOME's cyan frame on the game row and OCRs the game name above it, so a launch after the HOME order changed no longer presses A on whatever tile is first (console B, 2026-11-14: FireRed opened instead of PLZA). Tested with NintendoSwitch::HomeTileReader on six console B frames (CommandLineTests eae469773: FireRed and Z-A on the first tile, Z-A on the second, the user select over HOME with no tile).

What the three games do today:

PLZA (#335 plza/story-engine, #471) FRLG (#458 frlg/stage20-league) BDSP (#353 bdsp/story-engine)
Entry game.reload: go_home + reset_game_from_home(..., backup) load_save: in-game soft_reset (A+B+Select+Start); RNG: rng_reset_and_return_home load_save: reset_game_from_home(...), assumes HOME
HOME tile blind: from_home_close_and_reopen_game reopens the selected tile blind (soft reset never leaves the game) blind; the new-game intro refuses to start on HOME because of this
Close/launch X, A to close, A to launch, update menu tolerated RNG path: user select, update menu, CheckOnline popup, black screen as PLZA
Title mash A until black screen; dialog → B mash A until white screen / LoadMenu, A on Continue mash ZL until the black screen ends
Latest vs backup next_start_load_action: latest, then backup when the start check fails; title Up, B+X; backup arrow → A latest only latest only
Game prompts BlueDialog → B "Handle Online License Check" (HOME for a few s), recap mashed with B none
End check black screen gone + 1 s grace black screen over + B mash + random wait black screen over + 1 s grace

How each game's policy would fill in:

Policy field PLZA FRLG BDSP
tile_selected HOME's selected-title read as "Pokémon Legends: Z-A" "Pokémon FireRed/LeafGreen" "Pokémon Brilliant Diamond/Shining Pearl"
title / title_press "Press A" title / A title / A title / ZL
backup_save Up, then B+X held 1 s none none
new_game new-game intro (#471's first screen) Oak's intro text intro's language/first dialog
prompts close software (A), user select (A), update (A), backup arrow (A), blue dialog (B) close software, user select, update, CheckOnline (A), load menu Continue (A), recap (B, more presses) close software, user select, update
overworld PLAYER_CAN_MOVE from its backend PLAYER_CAN_MOVE PLAYER_CAN_MOVE (HOME is read first, so HOME's plain screen no longer passes)

PLZA's latest-then-backup choice (next_start_load_action) stays in PLZA and calls the launch once per save. The Switch prompts (close software, user select, update) are the same in every game, so this PR also carries their one shared helper, Pokemon::switch_launch_prompts(console) in Pokemon_StorySwitchPrompts.h, moved unchanged from #335; each game's policy starts its prompts with it. HOME is read before the prompts, and that stays safe for the user select: HomeMenuDetector does not fire on the user select over HOME (UserSelectOverHome.png: the dimmed top bar differs from the dialog's white bottom row by about 159, the limit is 20). Recommended adoption order: PLZA first (its run failed tonight and it already reloads from HOME, so the swap is direct), then BDSP (same reset-from-HOME shape, and it removes the intro's HOME refusal), then FRLG (its reload is an in-game soft reset and the license check needs the most screens; its RNG hard reset stays as is).

🤖 Generated with Claude Code

https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss

One driver for every game: a per-game StoryLaunchPolicy (HOME tile check,
title, backup-save presses, prompts such as the license check, the
overworld judge) and launch_story_game(), which looks, does one thing,
counts each screen's presses and ends only on a settled overworld. It
never starts a new game. No game uses it yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…after the launch

The update prompt needs the cursor moved before A, and PLZA's title and
dialog checks are loose enough to match the game in play, where a press
would answer the story. StoryLaunchPrompt::before presses before the
prompt's press; StoryLaunchPrompt::after_launch and
StoryLaunchPolicy::title_after_launch read those screens only once the
launch closed or launched the game.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine and others added 2 commits November 14, 2026 02:09
NintendoSwitch_HomeTileReader finds HOME's cyan frame on the game row and
reads the game name HOME writes above the row. switch_home_tile_named()
turns it into a launch policy's tile check, so a game names its tile
instead of trusting whatever tile is selected (console B, 2026-11-14: a
blind launch opened FireRed after the HOME order changed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine added a commit that referenced this pull request Nov 14, 2026
Brings the HOME tile reader; the CommandLineTests pin moves to eae469773,
which adds the HomeTileReader frames on top of 95b9aa8b9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine added a commit that referenced this pull request Nov 14, 2026
Pokemon_StorySwitchPrompts.{h,cpp} come unchanged from plza/story-engine
(723921b). The Close software dialog, the user select and the update
prompt are the same in every game, so the shared launch owns them and
FRLG, BDSP and PLZA use this one copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine and others added 2 commits November 14, 2026 02:44
On console B (FRLG, 2026-11-14 02:41) HOME showed for about 1.5 s after
the launch's A on the tile, and each look there pressed A again until
the launch failed as stuck on HOME, while the game was booting. After
that A, HOME now waits for up to the policy's launch_wait (30 s, as the
FRLG RNG reset's wait for the boot) before another A, and moves no
cursor in that time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss

@dayfine dayfine left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: mergeable on the fork
Reviewed SHA: bb240f6

Verdict

APPROVED

Correctness pass on git diff origin/autostory/engine...origin/autostory/launch-from-home, then a style pass. CI green (it uses the fork's CommandLineTests at eae46977 for the HomeTileReader shots). No existing comments. I traced the driver through closed, suspended, title and overworld starts, KEEP and RESTART, and BACKUP, and found no wrong press. No blocking findings.

Should-fix

  1. Engine/Pokemon_StoryLaunch.cpp:46 with Engine/Pokemon_StoryLaunch.h:124 — read_launch_look() classifies SWITCH_HOME_MENU before the prompts. The launch_wait doc says HOME can still show with the user select in front of it. If so, the "user select" prompt (Pokemon_StorySwitchPrompts.cpp) is never answered while HOME is read: the driver waits out launch_wait (30 s), then tile_selected is false (the reader's "user select over HOME" case has no frame), and move_to_tile() (:134) presses Left/Right into the user select. Match prompts that can overlay HOME before the HOME check, or add a fake-backend case for the user select over HOME.
  2. Engine/Pokemon_StoryLaunch.cpp:154 — the tile search hardcodes Milliseconds(80), Milliseconds(400). Use a StoryLaunchPress (its defaults are the same values) or a policy field, like every other press in the driver.

Nits

  1. ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp:71 — this PR deletes an unrelated blank line, so a shared runner file shows a whitespace-only hunk.
  2. NintendoSwitch/Inference/NintendoSwitch_HomeTileReader.cpp:162 — const std::vector<HomeTileCase> HOME_TILE_CASES is a namespace-scope global with a destructor. A plain array, const HomeTileCase HOME_TILE_CASES[], as the AutoStory test tables use, avoids that.

…merged, review fixes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
@dayfine
dayfine changed the base branch from autostory/engine to nav/shared November 14, 2026 22:06
@dayfine
dayfine merged commit efe1ea0 into nav/shared Nov 14, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant