44 *
55 */
66
7+ #include " Common/Cpp/PrettyPrint.h"
78#include " CommonFramework/Exceptions/OperationFailedException.h"
8- #include " CommonFramework/ProgramStats/StatsTracking.h"
9- #include " CommonFramework/VideoPipeline/VideoFeed.h"
10- #include " CommonTools/Async/InferenceRoutines.h"
9+ #include " CommonFramework/InferenceInfra/InferenceRoutines.h"
1110#include " CommonFramework/Notifications/ProgramNotifications.h"
11+ #include " CommonFramework/Tools/VideoResolutionCheck.h"
12+ #include " CommonFramework/Tools/StatsTracking.h"
1213#include " NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
13- #include " Pokemon/Pokemon_Strings.h"
14- #include " PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.h"
14+ #include " NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
1515#include " PokemonRSE/Inference/Sounds/PokemonRSE_ShinySoundDetector.h"
1616#include " PokemonRSE/PokemonRSE_Navigation.h"
1717#include " PokemonRSE_AudioStarterReset.h"
@@ -23,12 +23,12 @@ namespace PokemonRSE{
2323AudioStarterReset_Descriptor::AudioStarterReset_Descriptor ()
2424 : SingleSwitchProgramDescriptor(
2525 " PokemonRSE:AudioStarterReset" ,
26- Pokemon::STRING_POKEMON + " RSE" , " Starter Reset (Ruby/Sapphire) " ,
26+ " Pokemon RSE" , " [RS] Starter Reset - Audio only " ,
2727 " ComputerControl/blob/master/Wiki/Programs/PokemonRSE/AudioStarterReset.md" ,
28- " Soft reset for a shiny starter. Ruby and Sapphire only." ,
29- FeedbackType::VIDEO_AUDIO ,
28+ " Soft reset for a shiny starter. Ruby and Sapphire only. WIP, audio recognition does not work well. " ,
29+ FeedbackType::AUDIO ,
3030 AllowCommandsWhenRunning::DISABLE_COMMANDS,
31- {SerialPABotBase::OLD_NINTENDO_SWITCH_DEFAULT_REQUIREMENTS}
31+ PABotBaseLevel::PABOTBASE_12KB
3232 )
3333{}
3434
@@ -61,14 +61,26 @@ AudioStarterReset::AudioStarterReset()
6161 LockMode::LOCK_WHILE_RUNNING,
6262 Target::treecko
6363 )
64+ , POOCH_WAIT(
65+ " <b>Battle start wait:</b><br>Time for battle to start and for Poochyena to appear. Make sure to add extra time in case the Poochyena is shiny." ,
66+ LockMode::LOCK_WHILE_RUNNING,
67+ TICKS_PER_SECOND,
68+ " 6 * TICKS_PER_SECOND"
69+ )
70+ , STARTER_WAIT(
71+ " <b>Send out starter wait:</b><br>After pressing A to send out your selected starter, wait this long for the animation. Make sure to add extra time in case it is shiny." ,
72+ LockMode::LOCK_WHILE_RUNNING,
73+ TICKS_PER_SECOND,
74+ " 6 * TICKS_PER_SECOND"
75+ )
6476 , NOTIFICATION_SHINY_POOCH(
6577 " Shiny Poochyena" ,
66- false , false , ImageAttachmentMode::JPG,
78+ false , false ,
6779 {" Notifs" }
6880 )
6981 , NOTIFICATION_SHINY_STARTER(
7082 " Shiny Starter" ,
71- true , true , ImageAttachmentMode::JPG ,
83+ true , false ,
7284 {" Notifs" , " Showcase" }
7385 )
7486 , NOTIFICATION_STATUS_UPDATE(" Status Update" , true , false , std::chrono::seconds(3600 ))
@@ -83,14 +95,12 @@ AudioStarterReset::AudioStarterReset()
8395 PA_ADD_OPTION (NOTIFICATIONS);
8496}
8597
86- void AudioStarterReset::program (SingleSwitchProgramEnvironment& env, SwitchControllerContext& context){
98+ void AudioStarterReset::program (SingleSwitchProgramEnvironment& env, BotBaseContext& context){
99+ // assert_16_9_720p_min(env.logger(), env.console);
87100 AudioStarterReset_Descriptor::Stats& stats = env.current_stats <AudioStarterReset_Descriptor::Stats>();
88101
89102 /*
90103 * Settings: Text Speed fast.
91- * Full screen, no filter? The device I'm using to test has similar looking output, but I don't have switch online+.
92- * If on a retro handheld, make sure the screen matches that of NSO+.
93- *
94104 * Setup: Stand in front of the Professor's bag and save the game.
95105 *
96106 * Required to fight, so have to do the SR method instead of run away
@@ -101,9 +111,8 @@ void AudioStarterReset::program(SingleSwitchProgramEnvironment& env, SwitchContr
101111
102112 bool shiny_starter = false ;
103113 while (!shiny_starter) {
104- float shiny_coefficient = 1.0 ;
114+
105115 ShinySoundDetector pooch_detector (env.console , [&](float error_coefficient) -> bool {
106- shiny_coefficient = error_coefficient;
107116 return true ;
108117 });
109118
@@ -122,95 +131,77 @@ void AudioStarterReset::program(SingleSwitchProgramEnvironment& env, SwitchContr
122131 break ;
123132 default :
124133 OperationFailedException::fire (
125- ErrorReport::SEND_ERROR_REPORT,
126- " AudioStarterReset: Invalid target." ,
127- env.console
134+ env.console , ErrorReport::SEND_ERROR_REPORT,
135+ " AudioStarterReset: Invalid target."
128136 );
129137 break ;
130138 }
131139 pbf_mash_button (context, BUTTON_A, 540 );
132- context.wait_for_all_requests ();
133-
134140 env.log (" Starter selected. Checking for shiny Poochyena." );
135- AdvanceBattleDialogWatcher pooch_appeared (COLOR_YELLOW);
136141
137- int res = run_until<SwitchControllerContext>(
142+
143+ int ret = run_until (
138144 env.console , context,
139- [&](SwitchControllerContext& context) {
140- int ret = wait_until (
141- env.console , context,
142- std::chrono::seconds (20 ),
143- {{pooch_appeared}}
144- );
145- if (ret == 0 ) {
146- env.log (" Advance arrow detected." );
147- }
148- pbf_wait (context, 125 );
145+ [&](BotBaseContext& context){
146+ // Wait for battle to start and for Pooch battle cry
147+ pbf_wait (context, POOCH_WAIT);
148+
149149 context.wait_for_all_requests ();
150+
150151 },
151152 {{pooch_detector}}
152153 );
153154 pooch_detector.throw_if_no_sound ();
154- if (res == 0 ){
155+ if (ret == 0 ){
155156 env.log (" Shiny Poochyena detected!" );
156157 stats.poochyena ++;
157- env.update_stats ();
158- send_program_notification (env, NOTIFICATION_SHINY_POOCH, COLOR_YELLOW, " Shiny Poochyena found" , {}, " " , env.console .video ().snapshot (), true );
158+ send_program_status_notification (env, NOTIFICATION_SHINY_POOCH, " Shiny Poochyena found." );
159159 }
160160 else {
161161 env.log (" Poochyena is not shiny." );
162162 }
163- context.wait_for_all_requests ();
164163
165- float shiny_coefficient2 = 1.0 ;
166164 ShinySoundDetector starter_detector (env.console , [&](float error_coefficient) -> bool {
167- shiny_coefficient2 = error_coefficient;
168165 return true ;
169166 });
170167
171- BattleMenuWatcher battle_menu (COLOR_RED);
172- int res2 = run_until<SwitchControllerContext>(
168+ // Press A to send out your selected starter
169+ env.log (" Sending out selected starter." );
170+ pbf_press_button (context, BUTTON_A, 40 , 40 );
171+
172+ int ret2 = run_until (
173173 env.console , context,
174- [&](SwitchControllerContext& context) {
175- env.log (" Sending out selected starter." );
176- pbf_press_button (context, BUTTON_A, 40 , 40 );
177-
178- int ret = wait_until (
179- env.console , context,
180- std::chrono::seconds (20 ),
181- {{battle_menu}}
182- );
183- if (ret == 0 ) {
184- env.log (" Battle menu detecteed!" );
185- }
186- pbf_wait (context, 125 );
174+ [&](BotBaseContext& context){
175+ env.log (" Wait for starter to come out." );
176+ pbf_wait (context, STARTER_WAIT);
187177 context.wait_for_all_requests ();
188178 },
189179 {{starter_detector}}
190180 );
191181 starter_detector.throw_if_no_sound ();
192- context.wait_for_all_requests ();
193- if (res2 == 0 ){
182+ if (ret2 == 0 ){
194183 env.log (" Shiny starter detected!" );
195184 stats.shinystarter ++;
196- env.update_stats ();
197- send_program_notification (env, NOTIFICATION_SHINY_STARTER, COLOR_YELLOW, " Shiny starter found!" , {}, " " , env.console .video ().snapshot (), true );
185+
186+ send_program_status_notification (env, NOTIFICATION_SHINY_STARTER, " Shiny starter found!" );
187+
198188 shiny_starter = true ;
189+ break ;
199190 }
200191 else {
201192 env.log (" Starter is not shiny." );
202- env.log (" Soft resetting." );
203- send_program_status_notification (
204- env, NOTIFICATION_STATUS_UPDATE,
205- " Soft resetting."
206- );
207- stats.resets ++;
208- env.update_stats ();
209- soft_reset (env.program_info (), env.console , context);
210193 }
194+
195+ env.log (" Soft resetting." );
196+ send_program_status_notification (
197+ env, NOTIFICATION_STATUS_UPDATE,
198+ " Soft resetting."
199+ );
200+ soft_reset (env.program_info (), env.console , context);
201+ stats.resets ++;
211202 }
212203
213- // if system set to nintendo switch, have go home when done option?
204+ // TODO: if system set to nintendo switch, have go home when done option
214205
215206 send_program_finished_notification (env, NOTIFICATION_PROGRAM_FINISH);
216207}
0 commit comments