From 2223fe7863de2aaf7f409a86e4b8e6ed37b67418 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 19 Mar 2022 20:11:53 -0500 Subject: [PATCH] [nostalgia/core] Rename event handler to update handler --- src/nostalgia/core/context.hpp | 2 +- src/nostalgia/core/event.hpp | 4 ++-- src/nostalgia/core/gba/core.arm.cpp | 6 +++--- src/nostalgia/core/gba/core.cpp | 6 +++--- src/nostalgia/core/glfw/core.cpp | 2 +- src/nostalgia/core/glfw/core.hpp | 2 +- src/nostalgia/core/headless/core.cpp | 2 +- src/nostalgia/player/app.cpp | 2 +- src/nostalgia/studio/main.cpp | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/nostalgia/core/context.hpp b/src/nostalgia/core/context.hpp index ba4ed69d8..1606279b4 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 a93a2f79c..ea1e7546b 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 3055b2dc6..ebd36528a 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 a2969a743..3131d839e 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 fbf4b2759..debfa8fbe 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 e76ea5734..3305f7032 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 63954fb03..9d324474b 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 63ab0854c..eeb5ff70a 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 f9d084181..90e06a798 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);