From 3c056276c1c60c9c4f7c0baa3887057cfd7e6837 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Mon, 20 Jan 2025 23:19:07 -0600 Subject: [PATCH] [turbine,nostalgia] Cleanup --- .../modules/gfx/include/nostalgia/gfx/color.hpp | 2 +- .../modules/gfx/include/nostalgia/gfx/context.hpp | 9 ++------- .../modules/gfx/include/nostalgia/gfx/gfx.hpp | 10 +++++----- src/nostalgia/modules/gfx/src/gba/context.cpp | 6 +++--- src/nostalgia/modules/gfx/src/keel/keelmodule.cpp | 4 ++-- src/nostalgia/modules/gfx/src/opengl/context.cpp | 4 ++-- src/nostalgia/modules/gfx/src/opengl/gfx.cpp | 4 ++-- .../tilesheeteditor/commands/cutpastecommand.hpp | 4 ++-- .../studio/tilesheeteditor/tilesheeteditor-imgui.cpp | 6 +++--- .../modules/scene/src/studio/sceneeditorview.hpp | 2 +- src/olympic/turbine/include/turbine/context.hpp | 6 +----- src/olympic/turbine/include/turbine/turbine.hpp | 4 ++-- src/olympic/turbine/src/gba/context.cpp | 4 ++-- src/olympic/turbine/src/gba/turbine.cpp | 4 ++-- src/olympic/turbine/src/glfw/context.cpp | 4 ++-- src/olympic/turbine/src/glfw/turbine.cpp | 8 ++++---- src/olympic/turbine/src/turbine.cpp | 2 +- 17 files changed, 37 insertions(+), 46 deletions(-) diff --git a/src/nostalgia/modules/gfx/include/nostalgia/gfx/color.hpp b/src/nostalgia/modules/gfx/include/nostalgia/gfx/color.hpp index 4a41a9d9..68f17a59 100644 --- a/src/nostalgia/modules/gfx/include/nostalgia/gfx/color.hpp +++ b/src/nostalgia/modules/gfx/include/nostalgia/gfx/color.hpp @@ -12,7 +12,7 @@ namespace nostalgia::gfx { using Color16 = uint16_t; /** - * Nostalgia Core logically uses 16 bit colors, but must translate that to 32 + * Nostalgia logically uses 16 bit colors, but must translate that to 32 * bit colors in some implementations. */ using Color32 = uint32_t; diff --git a/src/nostalgia/modules/gfx/include/nostalgia/gfx/context.hpp b/src/nostalgia/modules/gfx/include/nostalgia/gfx/context.hpp index 8ccb0d1f..d4448e2e 100644 --- a/src/nostalgia/modules/gfx/include/nostalgia/gfx/context.hpp +++ b/src/nostalgia/modules/gfx/include/nostalgia/gfx/context.hpp @@ -4,10 +4,7 @@ #pragma once -#include -#include -#include -#include +#include #include @@ -19,9 +16,7 @@ class Context; void safeDelete(Context *ctx) noexcept; -using ContextUPtr = ox::UPtr; - -ox::Result init(turbine::Context &tctx, InitParams const¶ms = {}) noexcept; +ox::Result> init(turbine::Context &tctx, InitParams const¶ms = {}) noexcept; keel::Context &keelCtx(Context &ctx) noexcept; diff --git a/src/nostalgia/modules/gfx/include/nostalgia/gfx/gfx.hpp b/src/nostalgia/modules/gfx/include/nostalgia/gfx/gfx.hpp index d2a256fe..86516107 100644 --- a/src/nostalgia/modules/gfx/include/nostalgia/gfx/gfx.hpp +++ b/src/nostalgia/modules/gfx/include/nostalgia/gfx/gfx.hpp @@ -16,7 +16,7 @@ namespace nostalgia::gfx { struct Sprite { - static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Sprite"; + static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.Sprite"; static constexpr auto TypeVersion = 1; bool enabled = false; int x = 0; @@ -46,7 +46,7 @@ OX_MODEL_BEGIN(Sprite) OX_MODEL_END() struct BgTile { - static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.BgTile"; + static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.BgTile"; static constexpr auto TypeVersion = 1; unsigned tileIdx = 0; unsigned palBank = 0; @@ -62,7 +62,7 @@ OX_MODEL_BEGIN(BgTile) OX_MODEL_END() struct TileSheetSetEntrySection { - static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSetEntrySection"; + static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.TileSheetSetEntrySection"; static constexpr auto TypeVersion = 1; int32_t begin = 0; int32_t tiles = 0; @@ -78,7 +78,7 @@ OX_MODEL_BEGIN(TileSheetSetEntrySection) OX_MODEL_END() struct TileSheetSetEntry { - static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSetEntry"; + static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.TileSheetSetEntry"; static constexpr auto TypeVersion = 1; ox::FileAddress tilesheet; ox::Vector sections; @@ -90,7 +90,7 @@ OX_MODEL_BEGIN(TileSheetSetEntry) OX_MODEL_END() struct TileSheetSet { - static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSet"; + static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.TileSheetSet"; static constexpr auto TypeVersion = 1; static constexpr auto Preloadable = true; int32_t bpp = 0; diff --git a/src/nostalgia/modules/gfx/src/gba/context.cpp b/src/nostalgia/modules/gfx/src/gba/context.cpp index 9f7be14c..fd9c1106 100644 --- a/src/nostalgia/modules/gfx/src/gba/context.cpp +++ b/src/nostalgia/modules/gfx/src/gba/context.cpp @@ -19,10 +19,10 @@ Context::Context(turbine::Context &tctx) noexcept: turbineCtx(tctx) { ox::Error initGfx(Context &ctx, InitParams const&) noexcept; -ox::Result init(turbine::Context &tctx, InitParams const¶ms) noexcept { +ox::Result> init(turbine::Context &tctx, InitParams const¶ms) noexcept { auto ctx = ox::make_unique(tctx); OX_RETURN_ERROR(initGfx(*ctx, params)); - return ContextUPtr(std::move(ctx)); + return ox::UPtr(std::move(ctx)); } keel::Context &keelCtx(Context &ctx) noexcept { @@ -33,4 +33,4 @@ turbine::Context &turbineCtx(Context &ctx) noexcept { return ctx.turbineCtx; } -} \ No newline at end of file +} diff --git a/src/nostalgia/modules/gfx/src/keel/keelmodule.cpp b/src/nostalgia/modules/gfx/src/keel/keelmodule.cpp index a334c863..346df56e 100644 --- a/src/nostalgia/modules/gfx/src/keel/keelmodule.cpp +++ b/src/nostalgia/modules/gfx/src/keel/keelmodule.cpp @@ -4,7 +4,6 @@ #include -#include #include #include @@ -29,7 +28,7 @@ static class: public keel::Module { public: [[nodiscard]] ox::String id() const noexcept override { - return ox::String("net.drinkingtea.nostalgia.core"); + return ox::String{"net.drinkingtea.nostalgia.gfx"}; } [[nodiscard]] @@ -92,6 +91,7 @@ static class: public keel::Module { }, }; } + } const mod; keel::Module const*keelModule() noexcept { diff --git a/src/nostalgia/modules/gfx/src/opengl/context.cpp b/src/nostalgia/modules/gfx/src/opengl/context.cpp index 45e0d795..7c6e2da9 100644 --- a/src/nostalgia/modules/gfx/src/opengl/context.cpp +++ b/src/nostalgia/modules/gfx/src/opengl/context.cpp @@ -23,10 +23,10 @@ Context::~Context() noexcept { shutdownGfx(*this); } -ox::Result init(turbine::Context &tctx, InitParams const¶ms) noexcept { +ox::Result> init(turbine::Context &tctx, InitParams const¶ms) noexcept { auto ctx = ox::make_unique(tctx, params); OX_RETURN_ERROR(initGfx(*ctx, params)); - return ContextUPtr(ctx.release()); + return ox::UPtr(ctx.release()); } keel::Context &keelCtx(Context &ctx) noexcept { diff --git a/src/nostalgia/modules/gfx/src/opengl/gfx.cpp b/src/nostalgia/modules/gfx/src/opengl/gfx.cpp index c35ba026..bed68f7a 100644 --- a/src/nostalgia/modules/gfx/src/opengl/gfx.cpp +++ b/src/nostalgia/modules/gfx/src/opengl/gfx.cpp @@ -650,7 +650,7 @@ ox::Error loadSpriteTileSheet( CompactTileSheet const&ts, bool loadDefaultPalette) noexcept { OX_REQUIRE(tsd, normalizeTileSheet(ts)); - oxTracef("nostalgia.core.gfx.gl", "loadSpriteTexture: { w: {}, h: {} }", tsd.width, tsd.height); + oxTracef("nostalgia.gfx.gl", "loadSpriteTexture: { w: {}, h: {} }", tsd.width, tsd.height); ctx.spriteBlocks.tex = renderer::createTexture(tsd.width, tsd.height, tsd.pixels.data()); if (loadDefaultPalette) { OX_RETURN_ERROR(loadSpritePalette(ctx, ts.defaultPalette)); @@ -673,7 +673,7 @@ void setBgTile( int row, BgTile const&tile) noexcept { oxTracef( - "nostalgia.core.gfx.setBgTile", + "nostalgia.gfx.setBgTile", "bgIdx: {}, column: {}, row: {}, tile: {}, palBank: {}", bgIdx, column, row, tile.tileIdx, tile.palBank); const auto z = static_cast(bgIdx); diff --git a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/commands/cutpastecommand.hpp b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/commands/cutpastecommand.hpp index 5110bb5c..dc54f27c 100644 --- a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/commands/cutpastecommand.hpp +++ b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/commands/cutpastecommand.hpp @@ -14,13 +14,13 @@ OX_MODEL_FWD_DECL(class TileSheetClipboard); class TileSheetClipboard: public turbine::ClipboardObject { public: - static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.TileSheetClipboard"; + static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.studio.TileSheetClipboard"; static constexpr auto TypeVersion = 1; OX_MODEL_FRIEND(TileSheetClipboard); struct Pixel { - static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.TileSheetClipboard.Pixel"; + static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.studio.TileSheetClipboard.Pixel"; static constexpr auto TypeVersion = 1; uint16_t colorIdx = 0; ox::Point pt; diff --git a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp index 9c721f34..41c82e8d 100644 --- a/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp +++ b/src/nostalgia/modules/gfx/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp @@ -16,7 +16,7 @@ namespace nostalgia::gfx { namespace ig = studio::ig; struct TileSheetEditorConfig { - static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.TileSheetEditorConfig"; + static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.studio.TileSheetEditorConfig"; static constexpr auto TypeVersion = 1; TileSheet::SubSheetIdx activeSubsheet{}; }; @@ -47,8 +47,8 @@ static ox::Vector normalizePixelSizes( static ox::Vector normalizePixelArrangement( ox::Vector const&inPixels, - int cols, - int scale) { + int const cols, + int const scale) { auto const scalePt = ox::Point{scale, scale}; auto const width = cols * TileWidth; auto const height = static_cast(inPixels.size()) / width; diff --git a/src/nostalgia/modules/scene/src/studio/sceneeditorview.hpp b/src/nostalgia/modules/scene/src/studio/sceneeditorview.hpp index 6e21e40f..83c887b8 100644 --- a/src/nostalgia/modules/scene/src/studio/sceneeditorview.hpp +++ b/src/nostalgia/modules/scene/src/studio/sceneeditorview.hpp @@ -15,7 +15,7 @@ namespace nostalgia::scene { class SceneEditorView { private: - gfx::ContextUPtr m_cctx; + ox::UPtr m_cctx; SceneStatic const&m_sceneStatic; Scene m_scene; glutils::FrameBuffer m_frameBuffer; diff --git a/src/olympic/turbine/include/turbine/context.hpp b/src/olympic/turbine/include/turbine/context.hpp index c4f8416d..c59b1619 100644 --- a/src/olympic/turbine/include/turbine/context.hpp +++ b/src/olympic/turbine/include/turbine/context.hpp @@ -17,11 +17,7 @@ namespace turbine { class Context; -struct ContextDeleter { - void operator()(Context *p) noexcept; -}; - -using ContextUPtr = ox::UPtr; +void safeDelete(Context *p); void shutdown(Context &ctx) noexcept; diff --git a/src/olympic/turbine/include/turbine/turbine.hpp b/src/olympic/turbine/include/turbine/turbine.hpp index e5fa4b1d..b8e2eb02 100644 --- a/src/olympic/turbine/include/turbine/turbine.hpp +++ b/src/olympic/turbine/include/turbine/turbine.hpp @@ -16,9 +16,9 @@ namespace turbine { using TimeMs = uint64_t; -ox::Result init(ox::UPtr &&fs, ox::StringViewCR appName) noexcept; +ox::Result> init(ox::UPtr &&fs, ox::StringViewCR appName) noexcept; -ox::Result init(ox::StringViewCR fsPath, ox::StringViewCR appName) noexcept; +ox::Result> init(ox::StringViewCR fsPath, ox::StringViewCR appName) noexcept; ox::Error run(Context &ctx) noexcept; diff --git a/src/olympic/turbine/src/gba/context.cpp b/src/olympic/turbine/src/gba/context.cpp index 4cce844e..2d005120 100644 --- a/src/olympic/turbine/src/gba/context.cpp +++ b/src/olympic/turbine/src/gba/context.cpp @@ -6,8 +6,8 @@ namespace turbine { -void ContextDeleter::operator()(Context *p) noexcept { - ox::safeDelete(p); +void safeDelete(Context *p) { + delete p; } keel::Context const&keelCtx(Context const&ctx) noexcept { diff --git a/src/olympic/turbine/src/gba/turbine.cpp b/src/olympic/turbine/src/gba/turbine.cpp index 816723d8..29cd246f 100644 --- a/src/olympic/turbine/src/gba/turbine.cpp +++ b/src/olympic/turbine/src/gba/turbine.cpp @@ -58,7 +58,7 @@ OX_ALLOW_UNSAFE_BUFFERS_END return ox::Error(1); } -ox::Result init( +ox::Result> init( ox::UPtr &&fs, ox::StringViewCR appName) noexcept { auto ctx = ox::make_unique(); OX_RETURN_ERROR(keel::init(ctx->keelCtx, std::move(fs), appName)); @@ -68,7 +68,7 @@ ox::Result init( OX_RETURN_ERROR(initGfx(*ctx)); initTimer(); initIrq(); - return ox::UPtr(std::move(ctx)); + return ox::UPtr(std::move(ctx)); } void shutdown(Context&) noexcept { diff --git a/src/olympic/turbine/src/glfw/context.cpp b/src/olympic/turbine/src/glfw/context.cpp index 09f906fd..1aa34a24 100644 --- a/src/olympic/turbine/src/glfw/context.cpp +++ b/src/olympic/turbine/src/glfw/context.cpp @@ -8,8 +8,8 @@ namespace turbine { -void ContextDeleter::operator()(Context *p) noexcept { - ox::safeDelete(p); +void safeDelete(Context *p) { + delete p; } keel::Context const&keelCtx(Context const&ctx) noexcept { diff --git a/src/olympic/turbine/src/glfw/turbine.cpp b/src/olympic/turbine/src/glfw/turbine.cpp index b6997c58..d3ccfaf4 100644 --- a/src/olympic/turbine/src/glfw/turbine.cpp +++ b/src/olympic/turbine/src/glfw/turbine.cpp @@ -40,7 +40,7 @@ static void draw(GLFWwindow *window, int, int) noexcept { draw(ctx); } -ox::Result init( +ox::Result> init( ox::UPtr &&fs, ox::StringViewCR appName) noexcept { auto ctx = ox::make_unique(); OX_RETURN_ERROR(keel::init(ctx->keelCtx, std::move(fs), appName)); @@ -51,10 +51,10 @@ ox::Result init( OX_RETURN_ERROR(initGfx(*ctx)); glfwSetWindowSizeCallback(ctx->window, draw); ctx->mandatoryRefreshPeriodEnd = ticksMs(*ctx) + config::MandatoryRefreshPeriod; - return ox::UPtr(ctx.release()); + return ox::UPtr(ctx.release()); } -static void tickFps(Context &ctx, uint64_t nowMs) noexcept { +static void tickFps(Context &ctx, uint64_t const nowMs) noexcept { ++ctx.draws; if (ctx.draws >= 500) { auto const duration = static_cast(nowMs - ctx.prevFpsCheckTime) / 1000.0; @@ -114,7 +114,7 @@ TimeMs ticksMs(Context const&ctx) noexcept { return static_cast(now) - ctx.startTime; } -bool buttonDown(Context const&ctx, Key key) noexcept { +bool buttonDown(Context const&ctx, Key const key) noexcept { return (ctx.keysDown >> static_cast(key)) & 1; } diff --git a/src/olympic/turbine/src/turbine.cpp b/src/olympic/turbine/src/turbine.cpp index 2b525071..43901599 100644 --- a/src/olympic/turbine/src/turbine.cpp +++ b/src/olympic/turbine/src/turbine.cpp @@ -8,7 +8,7 @@ namespace turbine { -ox::Result init(ox::StringViewCR fsPath, ox::StringViewCR appName) noexcept { +ox::Result> init(ox::StringViewCR fsPath, ox::StringViewCR appName) noexcept { OX_REQUIRE_M(fs, keel::loadRomFs(fsPath)); return init(std::move(fs), appName); }