Skip to content

Commit d1fb3ce

Browse files
committed
Add faster-if-tick-precise enum for UI purposes. Fix the Item Printer RNG for SBB.
1 parent 83a23bd commit d1fb3ce

File tree

49 files changed

+314
-247
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+314
-247
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,8 @@ file(GLOB MAIN_SOURCES
900900
Source/NintendoSwitch/Programs/NintendoSwitch_FriendDelete.h
901901
Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.cpp
902902
Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.h
903+
Source/NintendoSwitch/Programs/NintendoSwitch_Navigation.cpp
904+
Source/NintendoSwitch/Programs/NintendoSwitch_Navigation.h
903905
Source/NintendoSwitch/Programs/NintendoSwitch_PreventSleep.cpp
904906
Source/NintendoSwitch/Programs/NintendoSwitch_PreventSleep.h
905907
Source/NintendoSwitch/Programs/NintendoSwitch_PushJoySticks.cpp

SerialPrograms/SerialPrograms.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ SOURCES += \
445445
Source/NintendoSwitch/Programs/NintendoSwitch_FriendCodeAdder.cpp \
446446
Source/NintendoSwitch/Programs/NintendoSwitch_FriendDelete.cpp \
447447
Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.cpp \
448+
Source/NintendoSwitch/Programs/NintendoSwitch_Navigation.cpp \
448449
Source/NintendoSwitch/Programs/NintendoSwitch_PreventSleep.cpp \
449450
Source/NintendoSwitch/Programs/NintendoSwitch_PushJoySticks.cpp \
450451
Source/NintendoSwitch/Programs/NintendoSwitch_SnapshotDumper.cpp \
@@ -1604,6 +1605,7 @@ HEADERS += \
16041605
Source/NintendoSwitch/Programs/NintendoSwitch_FriendCodeAdder.h \
16051606
Source/NintendoSwitch/Programs/NintendoSwitch_FriendDelete.h \
16061607
Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.h \
1608+
Source/NintendoSwitch/Programs/NintendoSwitch_Navigation.h \
16071609
Source/NintendoSwitch/Programs/NintendoSwitch_PreventSleep.h \
16081610
Source/NintendoSwitch/Programs/NintendoSwitch_PushJoySticks.h \
16091611
Source/NintendoSwitch/Programs/NintendoSwitch_SnapshotDumper.h \

SerialPrograms/Source/CommonFramework/Panels/UI/PanelElements.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ CollapsibleGroupBox* make_panel_header(
100100
const std::string& display_name,
101101
const std::string& doc_link,
102102
const std::string& description,
103-
const ControllerRequirements& requirements
103+
const ControllerRequirements& requirements,
104+
FasterIfTickPrecise faster_if_tick_precise
104105
){
105106
CollapsibleGroupBox* header = make_panel_header(parent, display_name, doc_link, description);
106107
QLayout* layout = header->widget()->layout();
@@ -116,7 +117,26 @@ CollapsibleGroupBox* make_panel_header(
116117
break;
117118
}
118119

119-
text = html_color_text("(This program does not have any special requirements.)", COLOR_BLUE);
120+
switch (faster_if_tick_precise){
121+
case PokemonAutomation::FasterIfTickPrecise::MUCH_FASTER:
122+
text = html_color_text(
123+
"(This program does not have any special controller requirements. "
124+
"However, it is strongly recommended to use a controller that is tick-precise since the program will run much faster.)",
125+
COLOR_DARKGREEN
126+
);
127+
break;
128+
case PokemonAutomation::FasterIfTickPrecise::FASTER:
129+
text = html_color_text(
130+
"(This program does not have any special controller requirements. "
131+
"However, it runs faster if the controller is tick-precise.)",
132+
COLOR_DARKGREEN
133+
);
134+
break;
135+
case PokemonAutomation::FasterIfTickPrecise::NOT_FASTER:
136+
text = html_color_text("(This program does not have any special controller requirements.)", COLOR_BLUE);
137+
break;
138+
}
139+
120140
}while (false);
121141

122142
QLabel* label = new QLabel(QString::fromStdString(text), header);

SerialPrograms/Source/CommonFramework/Panels/UI/PanelElements.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
#include <QLabel>
1212
#include "Common/Qt/CollapsibleGroupBox.h"
1313
#include "CommonFramework/Globals.h"
14+
#include "Controllers/ControllerCapability.h"
1415

1516
class QPushButton;
1617

1718
namespace PokemonAutomation{
1819

19-
class ControllerRequirements;
2020

2121

2222

@@ -40,7 +40,8 @@ CollapsibleGroupBox* make_panel_header(
4040
const std::string& display_name,
4141
const std::string& doc_link,
4242
const std::string& description,
43-
const ControllerRequirements& requirements
43+
const ControllerRequirements& requirements,
44+
FasterIfTickPrecise faster_if_tick_precise
4445
);
4546

4647

SerialPrograms/Source/Controllers/ControllerCapability.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@
3131
namespace PokemonAutomation{
3232

3333

34+
enum class FasterIfTickPrecise{
35+
NOT_FASTER,
36+
FASTER,
37+
MUCH_FASTER,
38+
};
39+
40+
3441

3542
enum class ControllerInterface{
3643
None,

SerialPrograms/Source/NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ void ssf_do_nothing(ProControllerContext& context, Milliseconds duration){
2424
}
2525

2626

27+
void ssf_press_button(ProControllerContext& context, Button button){
28+
Milliseconds delay = 3 * 8ms;
29+
Milliseconds hold = 5 * 8ms;
30+
Milliseconds cool = 3 * 8ms;
31+
Milliseconds timing_variation = context->timing_variation();
32+
delay += 2 * timing_variation;
33+
hold += timing_variation;
34+
cool += timing_variation;
35+
ssf_press_button(context, button, delay, hold, cool);
36+
}
2737
void ssf_press_button(
2838
ProControllerContext& context,
2939
Button button,
@@ -132,6 +142,16 @@ void ssf_issue_scroll(
132142
){
133143
context->issue_system_scroll(&context, direction, delay, hold, cool);
134144
}
145+
void ssf_issue_scroll(ProControllerContext& context, DpadPosition direction){
146+
Milliseconds delay = 3 * 8ms;
147+
Milliseconds hold = 5 * 8ms;
148+
Milliseconds cool = 3 * 8ms;
149+
Milliseconds timing_variation = context->timing_variation();
150+
delay += 2 * timing_variation;
151+
hold += timing_variation;
152+
cool += timing_variation;
153+
ssf_issue_scroll(context, direction, delay, hold, cool);
154+
}
135155

136156

137157

SerialPrograms/Source/NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ void ssf_do_nothing (ProControllerContext& context, Milliseconds duration);
3131

3232

3333

34+
void ssf_press_button(ProControllerContext& context, Button button);
3435
void ssf_press_button(
3536
ProControllerContext& context,
3637
Button button,
@@ -92,6 +93,7 @@ void ssf_mash_AZs (ProControllerContext& context, Milliseconds duration);
9293
#define SSF_SCROLL_RIGHT DPAD_RIGHT
9394
#define SSF_SCROLL_DOWN DPAD_DOWN
9495
#define SSF_SCROLL_LEFT DPAD_LEFT
96+
void ssf_issue_scroll(ProControllerContext& context, DpadPosition direction);
9597
void ssf_issue_scroll(
9698
ProControllerContext& context,
9799
DpadPosition direction,

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@
115115
#include "PokemonSwSh/MaxLair/Inference/PokemonSwSh_MaxLair_Detect_PokemonSwapMenu.h"
116116
#include "PokemonBDSP/Inference/PokemonBDSP_SelectionArrow.h"
117117
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_DigitEntry.h"
118+
#include "PokemonSV/Programs/PokemonSV_Navigation.h"
119+
#include "PokemonSV/Programs/Farming/PokemonSV_MaterialFarmerTools.h"
118120

119121

120122
#include <QPixmap>
@@ -169,6 +171,7 @@ TestProgram_Descriptor::TestProgram_Descriptor()
169171
FeedbackType::OPTIONAL_,
170172
AllowCommandsWhenRunning::ENABLE_COMMANDS,
171173
{SerialPABotBase::OLD_NINTENDO_SWITCH_DEFAULT_REQUIREMENTS},
174+
FasterIfTickPrecise::NOT_FASTER,
172175
1, 4, 1
173176
)
174177
{}
@@ -267,7 +270,7 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
267270
using namespace PokemonSwSh;
268271
// using namespace PokemonBDSP;
269272
// using namespace PokemonLA;
270-
// using namespace PokemonSV;
273+
using namespace PokemonSV;
271274

272275
[[maybe_unused]] Logger& logger = env.logger();
273276
[[maybe_unused]] ConsoleHandle& console = env.consoles[0];
@@ -278,6 +281,11 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
278281
VideoOverlaySet overlays(overlay);
279282

280283

284+
fly_from_paldea_to_blueberry_entrance(env.program_info(), console, context);
285+
286+
287+
288+
#if 0
281289
ssf_press_button(context, BUTTON_A, 0);
282290
ssf_do_nothing(context, 4);
283291
ssf_press_button(context, BUTTON_A, 0);
@@ -286,7 +294,7 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
286294
ssf_do_nothing(context, 4);
287295
ssf_press_button(context, BUTTON_A, 0);
288296
ssf_do_nothing(context, 4);
289-
297+
#endif
290298

291299

292300

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SwitchSystemOption.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,24 @@ Color pick_color(FeedbackType feedback){
3030
return Color();
3131
}
3232
#endif
33-
Color pick_color(const ControllerRequirements& requirements){
33+
Color pick_color(
34+
const ControllerRequirements& requirements,
35+
FasterIfTickPrecise faster_if_tick_precise
36+
){
3437
if (requirements.contains(ControllerFeature::NintendoSwitch_DateSkip)){
3538
return COLOR_RED;
3639
}
3740
if (requirements.contains(ControllerFeature::TickPrecise)){
3841
return COLOR_PURPLE;
3942
}
43+
switch (faster_if_tick_precise){
44+
case FasterIfTickPrecise::MUCH_FASTER:
45+
case FasterIfTickPrecise::FASTER:
46+
return COLOR_DARKGREEN;
47+
case FasterIfTickPrecise::NOT_FASTER:
48+
return COLOR_BLUE;
49+
}
50+
4051
return COLOR_BLUE;
4152
}
4253

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SwitchSystemOption.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ namespace NintendoSwitch{
2929

3030

3131
//Color pick_color(FeedbackType feedback);
32-
Color pick_color(const ControllerRequirements& requirements);
32+
Color pick_color(
33+
const ControllerRequirements& requirements,
34+
FasterIfTickPrecise faster_if_tick_precise
35+
);
3336

3437

3538
class SwitchSystemOption{

0 commit comments

Comments
 (0)