Skip to content

Commit 6f4a602

Browse files
committed
Move instruction scheduling from PABotBase to CC. Add millisecond timing APIs.
1 parent 16d3340 commit 6f4a602

File tree

46 files changed

+1198
-337
lines changed

Some content is hidden

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

46 files changed

+1198
-337
lines changed

ClientSource/Connection/MessageLogger.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ void MessageLogger::on_send(const BotBaseMessage& message, bool is_retransmit){
3131
if (message.type == PABB_MSG_REQUEST_CLOCK){
3232
print = false;
3333
}
34-
#if 0
34+
#if 1
3535
if (message.type == PABB_MSG_CONTROLLER_STATE){
36-
pabb_controller_state body;
37-
memcpy(&body, message.body.c_str(), sizeof(pabb_controller_state));
38-
print = body.ticks >= 5;
36+
// pabb_controller_state body;
37+
// memcpy(&body, message.body.c_str(), sizeof(pabb_controller_state));
38+
// print = body.ticks >= 5;
39+
print = false;
3940
}
4041
#endif
4142

SerialPrograms/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,8 @@ file(GLOB MAIN_SOURCES
611611
Source/Controllers/ControllerSelectorWidget.h
612612
Source/Controllers/NullController.cpp
613613
Source/Controllers/NullController.h
614+
Source/Controllers/SuperscalarScheduler.cpp
615+
Source/Controllers/SuperscalarScheduler.h
614616
Source/Controllers/SerialPABotBase/SerialPABotBase.cpp
615617
Source/Controllers/SerialPABotBase/SerialPABotBase.h
616618
Source/Controllers/SerialPABotBase/SerialPABotBase_Handle.cpp
@@ -847,7 +849,6 @@ file(GLOB MAIN_SOURCES
847849
Source/NintendoSwitch/Inference/NintendoSwitch_DetectHome.h
848850
Source/NintendoSwitch/NintendoSwitch_ConsoleHandle.cpp
849851
Source/NintendoSwitch/NintendoSwitch_ConsoleHandle.h
850-
Source/NintendoSwitch/NintendoSwitch_FixedInterval.h
851852
Source/NintendoSwitch/NintendoSwitch_MultiSwitchProgram.cpp
852853
Source/NintendoSwitch/NintendoSwitch_MultiSwitchProgram.h
853854
Source/NintendoSwitch/NintendoSwitch_Panels.cpp

SerialPrograms/SerialPrograms.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ SOURCES += \
312312
Source/Controllers/NullController.cpp \
313313
Source/Controllers/SerialPABotBase/SerialPABotBase.cpp \
314314
Source/Controllers/SerialPABotBase/SerialPABotBase_Handle.cpp \
315+
Source/Controllers/SuperscalarScheduler.cpp \
315316
Source/Integrations/DiscordIntegrationSettings.cpp \
316317
Source/Integrations/DiscordIntegrationTable.cpp \
317318
Source/Integrations/DiscordSettingsOption.cpp \
@@ -1428,6 +1429,7 @@ HEADERS += \
14281429
Source/Controllers/NullController.h \
14291430
Source/Controllers/SerialPABotBase/SerialPABotBase.h \
14301431
Source/Controllers/SerialPABotBase/SerialPABotBase_Handle.h \
1432+
Source/Controllers/SuperscalarScheduler.h \
14311433
Source/Integrations/DiscordIntegrationSettings.h \
14321434
Source/Integrations/DiscordIntegrationTable.h \
14331435
Source/Integrations/DiscordSettingsOption.h \
@@ -1533,7 +1535,6 @@ HEADERS += \
15331535
Source/NintendoSwitch/DevPrograms/TestProgramComputer.h \
15341536
Source/NintendoSwitch/DevPrograms/TestProgramSwitch.h \
15351537
Source/NintendoSwitch/NintendoSwitch_ConsoleHandle.h \
1536-
Source/NintendoSwitch/NintendoSwitch_FixedInterval.h \
15371538
Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramOption.h \
15381539
Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.h \
15391540
Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchSystemOption.h \

SerialPrograms/Source/CommonFramework/Globals.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ namespace PokemonAutomation{
2424

2525
const bool IS_BETA_VERSION = true;
2626
const int PROGRAM_VERSION_MAJOR = 0;
27-
const int PROGRAM_VERSION_MINOR = 50;
28-
const int PROGRAM_VERSION_PATCH = 19;
27+
const int PROGRAM_VERSION_MINOR = 51;
28+
const int PROGRAM_VERSION_PATCH = 1;
2929

3030
const std::string PROGRAM_VERSION_BASE =
3131
"v" + std::to_string(PROGRAM_VERSION_MAJOR) +

SerialPrograms/Source/CommonFramework/Recording/StreamRecorder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <QMediaRecorder>
1919
#include "Common/Cpp/PrettyPrint.h"
2020
#include "Common/Cpp/Concurrency/SpinPause.h"
21-
#include "Common/Qt/Redispatch.h"
21+
//#include "Common/Qt/Redispatch.h"
2222
#include "CommonFramework/GlobalSettingsPanel.h"
2323
#include "CommonFramework/VideoPipeline/Backends/VideoFrameQt.h"
2424
#include "CommonFramework/Recording/StreamHistoryOption.h"

SerialPrograms/Source/CommonTools/Async/InterruptableCommands.tpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,15 @@ void AsyncCommandSession<ControllerType>::dispatch(std::function<void(Controller
127127

128128
template <typename ControllerType>
129129
bool AsyncCommandSession<ControllerType>::cancel(std::exception_ptr exception) noexcept{
130+
// cout << "AsyncCommandSession::cancel()" << endl;
130131
if (Cancellable::cancel(exception)){
131132
return true;
132133
}
133134
std::lock_guard<std::mutex> lg(m_lock);
134135
if (m_current != nullptr){
135136
m_current->context.cancel(std::move(exception));
136137
}else{
138+
// cout << "AsyncCommandSession::cancel() - already cancelled" << endl;
137139
// REMOVE: Check that this can actually be deleted.
138140
// try{
139141
// m_controller.stop_all_commands();

SerialPrograms/Source/Controllers/ControllerSession.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class ControllerSession{
3838
const ControllerRequirements& requirements
3939
);
4040

41+
Logger& logger(){
42+
return m_logger;
43+
}
4144
const ControllerRequirements& requirements(){
4245
return m_requirements;
4346
}
@@ -75,21 +78,22 @@ class ControllerSession{
7578
// Try to run the following lambda on the underlying controller type.
7679
// Returns true if successful.
7780
template <typename ControllerType, typename Lambda>
78-
bool try_run(Lambda&& function){
81+
bool try_run(Lambda&& function) noexcept{
7982
std::lock_guard<std::mutex> lg(m_state_lock);
8083
if (!m_connection){
8184
return false;
8285
}
83-
84-
// This will be a cross-cast in most cases.
85-
ControllerType* child = dynamic_cast<ControllerType*>(m_connection.get());
86-
if (child == nullptr){
87-
throw InternalProgramError(
88-
&m_logger, PA_CURRENT_FUNCTION,
89-
"Incompatible controller type cast."
90-
);
86+
try{
87+
// This will be a cross-cast in most cases.
88+
ControllerType* child = dynamic_cast<ControllerType*>(m_connection.get());
89+
if (child == nullptr){
90+
m_logger.log("ControllerSession::try_run(): Incompatible controller type cast.", COLOR_RED);
91+
return false;
92+
}
93+
function(*child);
94+
}catch (...){
95+
return false;
9196
}
92-
function(*child);
9397
return true;
9498
}
9599

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const char* to_string(Features feature){
2020
switch (feature){
2121
case Features::TickPrecise: return "TickPrecise";
2222
case Features::NintendoSwitch_Basic: return "NintendoSwitch_Basic";
23+
case Features::NintendoSwitch_SSF: return "NintendoSwitch_SSF";
2324
case Features::NintendoSwitch_Macros: return "NintendoSwitch_Macros";
2425
case Features::NintendoSwitch_DateSkip: return "NintendoSwitch_DateSkip";
2526
}
@@ -33,7 +34,8 @@ const std::pair<std::string, std::set<std::string>> OLD_NINTENDO_SWITCH_DEFAULT_
3334
{
3435
to_string(SerialPABotBase::Features::TickPrecise),
3536
to_string(SerialPABotBase::Features::NintendoSwitch_Basic),
36-
to_string(SerialPABotBase::Features::NintendoSwitch_Macros),
37+
// to_string(SerialPABotBase::Features::NintendoSwitch_SSF),
38+
// to_string(SerialPABotBase::Features::NintendoSwitch_Macros),
3739
to_string(SerialPABotBase::Features::NintendoSwitch_DateSkip),
3840
}
3941
};
@@ -46,13 +48,15 @@ std::set<std::string> program_id_to_features(uint8_t id){
4648
return {
4749
to_string(Features::TickPrecise),
4850
to_string(Features::NintendoSwitch_Basic),
51+
to_string(Features::NintendoSwitch_SSF),
4952
to_string(Features::NintendoSwitch_Macros),
5053
// to_string(Features::NintendoSwitch_DateSkip),
5154
};
5255
case PABB_PID_PABOTBASE_31KB:
5356
return {
5457
to_string(Features::TickPrecise),
5558
to_string(Features::NintendoSwitch_Basic),
59+
to_string(Features::NintendoSwitch_SSF),
5660
to_string(Features::NintendoSwitch_Macros),
5761
to_string(Features::NintendoSwitch_DateSkip),
5862
};

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ extern const char NintendoSwitch_Basic[];
2323
enum class Features{
2424
TickPrecise,
2525
NintendoSwitch_Basic,
26+
NintendoSwitch_SSF,
2627
NintendoSwitch_Macros,
2728
NintendoSwitch_DateSkip,
2829
};

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Handle.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ void BotBaseHandle::thread_body(){
393393
}
394394
});
395395

396-
// REMOVE
397396
BotBaseControllerContext context(*m_botbase);
398397

399398
while (true){

0 commit comments

Comments
 (0)