diff --git a/src/nostalgia/core/context.hpp b/src/nostalgia/core/context.hpp index ba4ed69d..1606279b 100644 --- a/src/nostalgia/core/context.hpp +++ b/src/nostalgia/core/context.hpp @@ -67,7 +67,7 @@ class Context { friend void setBgStatus(Context *ctx, uint32_t status) noexcept; friend void setBgStatus(Context *ctx, unsigned bg, bool status) noexcept; friend void setClipboardText(Context *ctx, const ox::String &text) noexcept; - friend void setEventHandler(Context *ctx, event_handler h) noexcept; + friend void setUpdateHandler(Context *ctx, UpdateHandler h) noexcept; friend void setTile(Context *ctx, int layer, int column, int row, uint8_t tile) noexcept; friend void setWindowTitle(Context *ctx, const char *title) noexcept; diff --git a/src/nostalgia/core/event.hpp b/src/nostalgia/core/event.hpp index a93a2f79..ea1e7546 100644 --- a/src/nostalgia/core/event.hpp +++ b/src/nostalgia/core/event.hpp @@ -8,10 +8,10 @@ namespace nostalgia::core { class Context; -using event_handler = int(*)(Context*); +using UpdateHandler = int(*)(Context*); // Sets event handler that sleeps for the time given in the return value. The // sleep time is a minimum of ~16 milliseconds. -void setEventHandler(Context *ctx, event_handler) noexcept; +void setUpdateHandler(Context *ctx, UpdateHandler) noexcept; } diff --git a/src/nostalgia/core/gba/core.arm.cpp b/src/nostalgia/core/gba/core.arm.cpp index 3055b2dc..ebd36528 100644 --- a/src/nostalgia/core/gba/core.arm.cpp +++ b/src/nostalgia/core/gba/core.arm.cpp @@ -16,13 +16,13 @@ namespace nostalgia::core { extern volatile gba_timer_t g_timerMs; gba_timer_t g_wakeupTime; -event_handler g_eventHandler = nullptr; +UpdateHandler g_updateHandler = nullptr; ox::Error run(Context *ctx) noexcept { g_wakeupTime = 0; while (1) { - if (g_wakeupTime <= g_timerMs && g_eventHandler) { - auto sleepTime = g_eventHandler(ctx); + if (g_wakeupTime <= g_timerMs && g_updateHandler) { + auto sleepTime = g_updateHandler(ctx); if (sleepTime >= 0) { g_wakeupTime = g_timerMs + static_cast(sleepTime); } else { diff --git a/src/nostalgia/core/gba/core.cpp b/src/nostalgia/core/gba/core.cpp index a2969a74..3131d839 100644 --- a/src/nostalgia/core/gba/core.cpp +++ b/src/nostalgia/core/gba/core.cpp @@ -20,7 +20,7 @@ constexpr int NanoSecond = 1000000000; constexpr int MilliSecond = 1000; constexpr int TicksMs59ns = 65535 - (NanoSecond / MilliSecond) / 59.59; -extern event_handler g_eventHandler; +extern UpdateHandler g_updateHandler; extern volatile gba_timer_t g_timerMs; @@ -47,8 +47,8 @@ ox::Result> init(ox::UniquePtr fs, const return ctx; } -void setEventHandler(Context*, event_handler h) noexcept { - g_eventHandler = h; +void setUpdateHandler(Context*, UpdateHandler h) noexcept { + g_updateHandler = h; } uint64_t ticksMs(Context*) noexcept { diff --git a/src/nostalgia/core/glfw/core.cpp b/src/nostalgia/core/glfw/core.cpp index fbf4b275..debfa8fb 100644 --- a/src/nostalgia/core/glfw/core.cpp +++ b/src/nostalgia/core/glfw/core.cpp @@ -62,7 +62,7 @@ ox::Error run(Context *ctx) noexcept { return OxError(0); } -void setEventHandler(Context *ctx, event_handler h) noexcept { +void setUpdateHandler(Context *ctx, UpdateHandler h) noexcept { const auto id = ctx->windowerData(); id->eventHandler = h; } diff --git a/src/nostalgia/core/glfw/core.hpp b/src/nostalgia/core/glfw/core.hpp index e76ea573..3305f703 100644 --- a/src/nostalgia/core/glfw/core.hpp +++ b/src/nostalgia/core/glfw/core.hpp @@ -11,7 +11,7 @@ namespace nostalgia::core { struct GlfwImplData { struct GLFWwindow *window = nullptr; int64_t startTime = 0; - event_handler eventHandler = nullptr; + UpdateHandler eventHandler = nullptr; uint64_t wakeupTime = 0; }; diff --git a/src/nostalgia/core/headless/core.cpp b/src/nostalgia/core/headless/core.cpp index 63954fb0..9d324474 100644 --- a/src/nostalgia/core/headless/core.cpp +++ b/src/nostalgia/core/headless/core.cpp @@ -11,7 +11,7 @@ ox::Result> init(ox::UniquePtr, const cha return OxError(1); } -void setEventHandler(Context*, event_handler) noexcept { +void setUpdateHandler(Context*, UpdateHandler) noexcept { } uint64_t ticksMs(Context*) noexcept { diff --git a/src/nostalgia/player/app.cpp b/src/nostalgia/player/app.cpp index 63ab0854..eeb5ff70 100644 --- a/src/nostalgia/player/app.cpp +++ b/src/nostalgia/player/app.cpp @@ -35,7 +35,7 @@ ox::Error run(ox::UniquePtr fs) noexcept { oxReturnError(core::loadSpriteTileSheet(ctx.get(), 0, TileSheetAddr, PaletteAddr)); oxReturnError(core::initConsole(ctx.get())); core::puts(ctx.get(), 10, 9, "DOPENESS!!!"); - core::setEventHandler(ctx.get(), eventHandler); + core::setUpdateHandler(ctx.get(), eventHandler); return core::run(ctx.get()); } diff --git a/src/nostalgia/studio/main.cpp b/src/nostalgia/studio/main.cpp index f9d08418..90e06a79 100644 --- a/src/nostalgia/studio/main.cpp +++ b/src/nostalgia/studio/main.cpp @@ -33,7 +33,7 @@ static int eventHandler(core::Context *ctx) noexcept { static ox::Error run(ox::UniquePtr fs) noexcept { oxRequireM(ctx, core::init(std::move(fs), "NostalgiaStudio")); core::setWindowTitle(ctx.get(), "Nostalgia Studio"); - core::setEventHandler(ctx.get(), eventHandler); + core::setUpdateHandler(ctx.get(), eventHandler); core::setConstantRefresh(ctx.get(), false); studio::StudioContext studioCtx; core::setApplicationData(ctx.get(), &studioCtx);