Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "CommonTools/Random.h"
#include "CommonFramework/Exceptions/OperationFailedException.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
#include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h"
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
#include "PokemonFRLG_BlindNavigation.h"
Expand All @@ -16,26 +17,47 @@ namespace NintendoSwitch{
namespace PokemonFRLG{


void set_seed_after_delay(ProControllerContext& context, SeedButton SEED_BUTTON, int64_t SEED_DELAY){
// wait on title screen for the specified delay
pbf_wait(context, std::chrono::milliseconds(SEED_DELAY));
void set_seed_after_delay(ProControllerContext& context, SeedButton SEED_BUTTON, BlackoutButton BLACKOUT_BUTTON, int64_t SEED_DELAY){
// wait on title screen for the specified delay
// hold the "blackout" button starting from the black screen after the copyright text until getting to the continue screen
if (BLACKOUT_BUTTON != BlackoutButton::None){
Button b_button;
switch (BLACKOUT_BUTTON){
case BlackoutButton::L:
b_button = BUTTON_L;
break;
case BlackoutButton::R:
b_button = BUTTON_R;
break;
default:
b_button = BUTTON_L;
}
Milliseconds blackout_wait = 3600ms; // wait for the copyright text to disappear
Milliseconds blackout_delay = std::chrono::milliseconds(SEED_DELAY) - blackout_wait;
Milliseconds blackout_hold = 30000ms; // wait for leaves/flames to appear on the title screen. It's okay if this is held over the seed button press
ssf_do_nothing(context, blackout_wait);
ssf_press_button(context, b_button, blackout_delay, blackout_hold, 0ms);
}else{
pbf_wait(context, std::chrono::milliseconds(SEED_DELAY));
}

// hold the specified button for a few seconds through the transition to the Continue Screen
Button button;
Button s_button;
switch (SEED_BUTTON){
case SeedButton::A:
button = BUTTON_A;
s_button = BUTTON_A;
break;
case SeedButton::Start:
button = BUTTON_PLUS;
s_button = BUTTON_PLUS;
break;
case SeedButton::L:
button = BUTTON_L;
s_button = BUTTON_L;
break;
default:
button = BUTTON_A;
s_button = BUTTON_A;
break;
}
pbf_press_button(context, button, 3000ms, 0ms);
pbf_press_button(context, s_button, 3000ms, 0ms);
}

void load_game_after_delay(ProControllerContext& context, uint64_t CONTINUE_SCREEN_DELAY){
Expand Down Expand Up @@ -564,14 +586,15 @@ void perform_blind_sequence(
ProControllerContext& context,
PokemonFRLG_RngTarget TARGET,
SeedButton SEED_BUTTON,
BlackoutButton BLACKOUT_BUTTON,
uint64_t SEED_DELAY,
uint64_t CONTINUE_SCREEN_DELAY,
uint64_t TEACHY_DELAY,
uint64_t INGAME_DELAY,
bool SAFARI_ZONE
){
pbf_press_button(context, BUTTON_A, 80ms, 0ms); // start the game from the Home screen
set_seed_after_delay(context, SEED_BUTTON, SEED_DELAY);
set_seed_after_delay(context, SEED_BUTTON, BLACKOUT_BUTTON, SEED_DELAY);
load_game_after_delay(context, CONTINUE_SCREEN_DELAY);
if (TEACHY_DELAY > 0){
wait_with_teachy_tv(context, TEACHY_DELAY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ namespace PokemonFRLG{
L
};

enum class BlackoutButton{
None,
L,
R
};

// checks seed, continue screen, and in-game timings for the specificed RNG manipulation target
// and fires an error if any of the timings are too short.
void check_timings(
Expand All @@ -68,6 +74,7 @@ namespace PokemonFRLG{
ProControllerContext& context,
PokemonFRLG_RngTarget TARGET,
SeedButton SEED_BUTTON,
BlackoutButton BLACKOUT_BUTTON,
uint64_t SEED_DELAY,
uint64_t CONTINUE_SCREEN_DELAY,
uint64_t TEACHY_DELAY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ void reset_and_perform_blind_sequence(
ProControllerContext& context,
PokemonFRLG_RngTarget TARGET,
SeedButton SEED_BUTTON,
BlackoutButton BLACKOUT_BUTTON,
uint64_t SEED_DELAY,
uint64_t CONTINUE_SCREEN_DELAY,
uint64_t TEACHY_DELAY,
Expand Down Expand Up @@ -185,8 +186,8 @@ void reset_and_perform_blind_sequence(
context.wait_for_all_requests();
int ret = run_until<ProControllerContext>(
console, context,
[TARGET, SEED_BUTTON, SEED_DELAY, CONTINUE_SCREEN_DELAY, TEACHY_DELAY, INGAME_DELAY, SAFARI_ZONE](ProControllerContext& context) {
perform_blind_sequence(context, TARGET, SEED_BUTTON, SEED_DELAY, CONTINUE_SCREEN_DELAY, TEACHY_DELAY, INGAME_DELAY, SAFARI_ZONE);
[TARGET, SEED_BUTTON, BLACKOUT_BUTTON, SEED_DELAY, CONTINUE_SCREEN_DELAY, TEACHY_DELAY, INGAME_DELAY, SAFARI_ZONE](ProControllerContext& context) {
perform_blind_sequence(context, TARGET, SEED_BUTTON, BLACKOUT_BUTTON, SEED_DELAY, CONTINUE_SCREEN_DELAY, TEACHY_DELAY, INGAME_DELAY, SAFARI_ZONE);
},
{ update_detector, user_selection_detector },
1000ms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void reset_and_perform_blind_sequence(
ProControllerContext& context,
PokemonFRLG_RngTarget TARGET,
SeedButton SEED_BUTTON,
BlackoutButton BLACKOUT_BUTTON,
uint64_t SEED_DELAY,
uint64_t CONTINUE_SCREEN_DELAY,
uint64_t TEACHY_DELAY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ RngHelper::RngHelper()
LockMode::LOCK_WHILE_RUNNING,
SeedButton::A
)
, EXTRA_BUTTON(
"<b>Extra Button:</b><br>"
"Additional button presses that affect the seed.",
{
{BlackoutButton::None, "None", "None"},
{BlackoutButton::L, "L", "Blackout L"},
{BlackoutButton::R, "R", "Blackout R"},
},
LockMode::LOCK_WHILE_RUNNING,
BlackoutButton::None
)
, SEED_DELAY(
"<b>Seed Delay Time (ms):</b><br>"
"The delay between starting the game and advancing past the title screen. Set this to match your target seed.",
Expand Down Expand Up @@ -181,6 +192,7 @@ RngHelper::RngHelper()
PA_ADD_OPTION(TARGET);
PA_ADD_OPTION(NUM_RESETS);
PA_ADD_OPTION(SEED_BUTTON);
PA_ADD_OPTION(EXTRA_BUTTON);
PA_ADD_OPTION(SEED_DELAY);
PA_ADD_OPTION(SEED_CALIBRATION);
PA_ADD_OPTION(CONTINUE_SCREEN_FRAMES);
Expand Down Expand Up @@ -252,8 +264,8 @@ void RngHelper::program(SingleSwitchProgramEnvironment& env, ProControllerContex

// handle the blind part
reset_and_perform_blind_sequence(
env.console, context,
TARGET, SEED_BUTTON, TOTAL_SEED_DELAY,
env.console, context, TARGET,
SEED_BUTTON, EXTRA_BUTTON, TOTAL_SEED_DELAY,
CONTINUE_SCREEN_DELAY, TEACHY_DELAY, INGAME_DELAY,
SAFARI_ZONE, PROFILE
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ class RngHelper : public SingleSwitchProgramInstance{
SimpleIntegerOption<uint64_t> NUM_RESETS;

EnumDropdownOption<SeedButton> SEED_BUTTON;
EnumDropdownOption<BlackoutButton> EXTRA_BUTTON;
SimpleIntegerOption<uint64_t> SEED_DELAY;
SimpleIntegerOption<int64_t> SEED_CALIBRATION;


SimpleIntegerOption<uint64_t> CONTINUE_SCREEN_FRAMES;
FloatingPointOption CONTINUE_SCREEN_CALIBRATION;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@ StarterRng::StarterRng()
LockMode::LOCK_WHILE_RUNNING,
SeedButton::A
)
, EXTRA_BUTTON(
"<b>Extra Button:</b><br>"
"Additional button presses that affect the seed.",
{
{BlackoutButton::None, "None", "None"},
{BlackoutButton::L, "L", "Blackout L"},
{BlackoutButton::R, "R", "Blackout R"},
},
LockMode::LOCK_WHILE_RUNNING,
BlackoutButton::None
)
, SEED_DELAY(
"<b>Seed Delay Time (ms):</b><br>The delay between starting the game and advancing past the title screen. Set this to match your target seed.",
LockMode::LOCK_WHILE_RUNNING,
Expand Down Expand Up @@ -186,6 +197,7 @@ StarterRng::StarterRng()
PA_ADD_OPTION(SEED);
PA_ADD_OPTION(SEED_LIST);
PA_ADD_OPTION(SEED_BUTTON);
PA_ADD_OPTION(EXTRA_BUTTON);
PA_ADD_OPTION(SEED_DELAY);
PA_ADD_OPTION(ADVANCES);
// PA_ADD_OPTION(CONTINUE_SCREEN_FRAMES);
Expand Down Expand Up @@ -1045,12 +1057,10 @@ void StarterRng::program(SingleSwitchProgramEnvironment& env, ProControllerConte

env.log("Resetting Game...");
reset_and_perform_blind_sequence(
env.console,
context,
PokemonFRLG_RngTarget::starters,
SEED_BUTTON, CALIBRATED_SEED_DELAY,
CONTINUE_SCREEN_DELAY,
0, INGAME_DELAY, false, PROFILE
env.console, context, PokemonFRLG_RngTarget::starters,
SEED_BUTTON, EXTRA_BUTTON, CALIBRATED_SEED_DELAY,
CONTINUE_SCREEN_DELAY, 0, INGAME_DELAY,
false, PROFILE
);
stats.resets++;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class StarterRng : public SingleSwitchProgramInstance{
StringOption SEED;
TextEditOption SEED_LIST;
EnumDropdownOption<SeedButton> SEED_BUTTON;
EnumDropdownOption<BlackoutButton> EXTRA_BUTTON;
SimpleIntegerOption<uint64_t> SEED_DELAY;

SimpleIntegerOption<uint64_t>ADVANCES;
Expand Down