[nostalgia/core] Add Context parameter to event_handler
This commit is contained in:
parent
80f98802b6
commit
0d405ec88a
@ -16,7 +16,7 @@
|
||||
|
||||
namespace nostalgia::core {
|
||||
|
||||
using event_handler = int(*)(void);
|
||||
using event_handler = int(*)(Context*);
|
||||
|
||||
[[nodiscard]] ox::Error init(Context *ctx);
|
||||
|
||||
|
@ -21,11 +21,11 @@ extern volatile gba_timer_t g_timerMs;
|
||||
gba_timer_t g_wakeupTime;
|
||||
event_handler g_eventHandler = nullptr;
|
||||
|
||||
ox::Error run(Context*) {
|
||||
ox::Error run(Context *ctx) {
|
||||
g_wakeupTime = 0;
|
||||
while (1) {
|
||||
if (g_wakeupTime <= g_timerMs && g_eventHandler) {
|
||||
auto sleepTime = g_eventHandler();
|
||||
auto sleepTime = g_eventHandler(ctx);
|
||||
if (sleepTime >= 0) {
|
||||
g_wakeupTime = g_timerMs + static_cast<unsigned>(sleepTime);
|
||||
} else {
|
||||
|
@ -17,7 +17,7 @@ using namespace nostalgia;
|
||||
static unsigned spriteX = 72;
|
||||
static unsigned spriteY = 64;
|
||||
|
||||
static int mainLoop() {
|
||||
static int mainLoop(core::Context*) {
|
||||
if (core::buttonDown(core::GamePad_Right)) {
|
||||
spriteX += 2;
|
||||
} else if (core::buttonDown(core::GamePad_Left)) {
|
||||
|
Loading…
Reference in New Issue
Block a user