summaryrefslogtreecommitdiff
path: root/GameCube/source/main.cpp
diff options
context:
space:
mode:
authorMaurice <maurice.henke@protonmail.com>2021-04-25 23:37:41 +0200
committerMaurice <maurice.henke@protonmail.com>2021-04-25 23:37:41 +0200
commitc62ad036fd9c562810f62765280b8e33538ac7a4 (patch)
treee1020ea3c9e439ec9ab699ee1e31577da758da81 /GameCube/source/main.cpp
parent5077687ded45a7685236ee4123a7b43cd176ebe2 (diff)
Basic Seed parsing and display control
Diffstat (limited to 'GameCube/source/main.cpp')
-rw-r--r--GameCube/source/main.cpp63
1 files changed, 46 insertions, 17 deletions
diff --git a/GameCube/source/main.cpp b/GameCube/source/main.cpp
index f4374ec8..39b663d3 100644
--- a/GameCube/source/main.cpp
+++ b/GameCube/source/main.cpp
@@ -5,32 +5,61 @@
#include <cstdio>
#include <cstring>
-#include "chronos/timer.h"
#include "patch.h"
-#include "tp/JFWSystem.h"
#include "tp/f_ap_game.h"
+#include "tp/m_do_controller_pad.h"
namespace mod
{
- using namespace libtp::chronos;
- void main()
+ // Bind extern global variables
+ libtp::display::Console* console = new libtp::display::Console();
+ rando::SeedSelector* seedSelector = new rando::SeedSelector();
+ rando::Randomizer* randomizer = nullptr;
+
+ bool consoleState = true;
+ void ( *return_fapGm_Execute )( void ) = nullptr;
+
+ uint32_t lastButtonInput = 0;
+
+ void main() { hookFunctions(); }
+
+ void hookFunctions()
{
- // Initialise rando-system
- return_fapGm_Execute = libtp::patch::hookFunction( libtp::tp::f_ap_game::fapGm_Execute, []() {
- mod::t->tick();
+ // Hook functions
+ return_fapGm_Execute = libtp::patch::hookFunction( libtp::tp::f_ap_game::fapGm_Execute, mod::handle_fapGm_Execute );
+ *console << "Functions have been hooked\n";
+ }
- mod::return_fapGm_Execute();
- } );
+ // TODO: Depending on the current state of the game we want this function to behave differently; i.e. there is no
+ // seedselector (required) when we're ingame; instead we will have the Randomizer
+ void handle_fapGm_Execute()
+ {
+ using namespace libtp;
+ using namespace tp::m_do_controller_pad;
+ uint32_t buttonInput = tp::m_do_controller_pad::cpadInfo.buttonInput;
- libtp::tp::jfw_system::systemConsole->consoleEnabled = true;
+ // handle button inputs only if buttons are being held that weren't held last time
+ if ( buttonInput && buttonInput != lastButtonInput )
+ {
+ if ( ( buttonInput & ( PadInputs::Button_R | PadInputs::Button_Z ) ) ==
+ ( PadInputs::Button_R | PadInputs::Button_Z ) )
+ {
+ consoleState = !consoleState;
+ display::setConsole( consoleState, 0 );
+ }
- t = new IntervalTimer( 120, []( Timer* timer ) {
- libtp::tp::jfw_system::systemConsole->consoleLine[timer->m_ExecCount].showLine = true;
- sprintf( libtp::tp::jfw_system::systemConsole->consoleLine[timer->m_ExecCount].line,
- "Timer Handler: #%" PRId32,
- timer->m_ExecCount );
- } );
+ // Handle Inputs if console is active
+ if ( consoleState )
+ {
+ if ( seedSelector->HandleInputs( buttonInput ) )
+ {
+ // print information
+ *console << seedSelector->m_StatusText << "\n";
+ }
+ }
+ }
- return;
+ lastButtonInput = buttonInput;
+ return return_fapGm_Execute();
}
} // namespace mod \ No newline at end of file