Skip to content

Commit 5c43164

Browse files
authored
Fix LZA game entry (#862)
1 parent 39594bd commit 5c43164

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_GameEntry.cpp

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,38 @@ bool gamemenu_to_ingame(
3535
Milliseconds enter_game_timeout
3636
){
3737
stream.log("Mashing A to enter game...");
38-
BlackScreenOverWatcher detector(COLOR_RED, {0.1, 0.04, 0.8, 0.3});
39-
pbf_mash_button(context, BUTTON_A, 500ms);
40-
context.wait_for_all_requests();
41-
stream.log("Waiting to enter game...");
42-
int ret = wait_until(
43-
stream, context,
44-
std::chrono::milliseconds(enter_game_timeout),
45-
{{detector}}
46-
);
47-
if (ret == 0){
48-
stream.log("Entered game!");
49-
return true;
50-
}else{
51-
stream.log("Timed out waiting to enter game.", COLOR_RED);
52-
return false;
38+
{
39+
BlackScreenWatcher detector(COLOR_RED, {0.1, 0.04, 0.8, 0.3});
40+
stream.log("Waiting to enter game...");
41+
int ret = run_until<ProControllerContext>(
42+
stream, context,
43+
[enter_game_timeout](ProControllerContext& context){
44+
pbf_mash_button(context, BUTTON_A, enter_game_timeout / 2);
45+
},
46+
{{detector}}
47+
);
48+
if (ret != 0){
49+
stream.log("Timed out waiting for black screen.", COLOR_RED);
50+
return false;
51+
}
52+
}
53+
54+
stream.log("Black screen detected");
55+
56+
{
57+
BlackScreenOverWatcher detector(COLOR_RED, {0.1, 0.04, 0.8, 0.3});
58+
int ret = wait_until(
59+
stream, context,
60+
std::chrono::milliseconds(enter_game_timeout / 2),
61+
{{detector}}
62+
);
63+
if (ret == 0){
64+
stream.log("Entered game!");
65+
return true;
66+
}else{
67+
stream.log("Timed out waiting to enter game.", COLOR_RED);
68+
return false;
69+
}
5370
}
5471
}
5572

0 commit comments

Comments
 (0)