diff --git a/src/nostalgia/core/CMakeLists.txt b/src/nostalgia/core/CMakeLists.txt index 3f294879..4a89e5f2 100644 --- a/src/nostalgia/core/CMakeLists.txt +++ b/src/nostalgia/core/CMakeLists.txt @@ -1,6 +1,5 @@ add_library( NostalgiaCore - context.cpp gfx.cpp keelmodule.cpp typeconv.cpp diff --git a/src/nostalgia/core/context.cpp b/src/nostalgia/core/context.cpp deleted file mode 100644 index a0b5af84..00000000 --- a/src/nostalgia/core/context.cpp +++ /dev/null @@ -1,3 +0,0 @@ -/* - * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ diff --git a/src/nostalgia/core/context.hpp b/src/nostalgia/core/context.hpp index 762899b6..5aa60ef5 100644 --- a/src/nostalgia/core/context.hpp +++ b/src/nostalgia/core/context.hpp @@ -9,7 +9,6 @@ #include #include -#include #include #include "initparams.hpp" @@ -27,11 +26,13 @@ class Context { Context(const Context &other) noexcept = delete; Context(const Context &&other) noexcept = delete; - auto &rom() noexcept { + const auto &rom() const noexcept { return *turbineCtx->rom; } }; +ox::Result> init(turbine::Context *tctx, const InitParams& = {}) noexcept; + } diff --git a/src/nostalgia/core/core.hpp b/src/nostalgia/core/core.hpp index 43551503..d1012459 100644 --- a/src/nostalgia/core/core.hpp +++ b/src/nostalgia/core/core.hpp @@ -4,10 +4,12 @@ #pragma once +#include "color.hpp" #include "context.hpp" - -namespace nostalgia::core { - -ox::Result> init(turbine::Context *tctx, const InitParams& = {}) noexcept; - -} +#include "gfx.hpp" +#include "initparams.hpp" +#include "keelmodule.hpp" +#include "palette.hpp" +#include "ptidxconv.hpp" +#include "tilesheet.hpp" +#include "typeconv.hpp" \ No newline at end of file diff --git a/src/nostalgia/core/gba/gfx.cpp b/src/nostalgia/core/gba/gfx.cpp index 169cd662..e49893b3 100644 --- a/src/nostalgia/core/gba/gfx.cpp +++ b/src/nostalgia/core/gba/gfx.cpp @@ -130,7 +130,7 @@ ox::Error loadBgTileSheet(Context *ctx, const ox::FileAddress &tilesheetAddr, const ox::FileAddress &paletteAddr) noexcept { oxRequire(tsStat, ctx->rom().stat(tilesheetAddr)); - oxRequire(ts, static_cast(&ctx->rom())->directAccess(tilesheetAddr)); + oxRequire(ts, static_cast(ctx->rom()).directAccess(tilesheetAddr)); GbaTileMapTarget target; target.pal.palette = MEM_BG_PALETTE; target.cbbData = &g_cbbData[cbb]; @@ -139,7 +139,7 @@ ox::Error loadBgTileSheet(Context *ctx, // load external palette if available if (paletteAddr) { oxRequire(palStat, ctx->rom().stat(paletteAddr)); - oxRequire(pal, static_cast(&ctx->rom())->directAccess(paletteAddr)); + oxRequire(pal, static_cast(ctx->rom()).directAccess(paletteAddr)); oxReturnError(ox::readMC(pal, palStat.size, &target.pal)); } // update bpp of all bgs with the updated cbb @@ -156,7 +156,7 @@ ox::Error loadSpriteTileSheet(Context *ctx, const ox::FileAddress &tilesheetAddr, const ox::FileAddress &paletteAddr) noexcept { oxRequire(tsStat, ctx->rom().stat(tilesheetAddr)); - oxRequire(ts, static_cast(&ctx->rom())->directAccess(tilesheetAddr)); + oxRequire(ts, static_cast(ctx->rom()).directAccess(tilesheetAddr)); GbaTileMapTarget target; target.pal.palette = MEM_SPRITE_PALETTE; target.tileMap = MEM_SPRITE_TILES; @@ -164,7 +164,7 @@ ox::Error loadSpriteTileSheet(Context *ctx, // load external palette if available if (paletteAddr) { oxRequire(palStat, ctx->rom().stat(paletteAddr)); - oxRequire(pal, static_cast(&ctx->rom())->directAccess(paletteAddr)); + oxRequire(pal, static_cast(ctx->rom()).directAccess(paletteAddr)); oxReturnError(ox::readMC(pal, palStat.size, &target.pal)); } return {}; @@ -174,7 +174,7 @@ ox::Error loadBgPalette(Context *ctx, unsigned, const ox::FileAddress &paletteAd GbaPaletteTarget target; target.palette = MEM_BG_PALETTE; oxRequire(palStat, ctx->rom().stat(paletteAddr)); - oxRequire(pal, static_cast(&ctx->rom())->directAccess(paletteAddr)); + oxRequire(pal, static_cast(ctx->rom()).directAccess(paletteAddr)); oxReturnError(ox::readMC(pal, palStat.size, &target)); return {}; } @@ -183,7 +183,7 @@ ox::Error loadSpritePalette(Context *ctx, unsigned cbb, const ox::FileAddress &p GbaPaletteTarget target; target.palette = &MEM_SPRITE_PALETTE[cbb]; oxRequire(palStat, ctx->rom().stat(paletteAddr)); - oxRequire(pal, static_cast(&ctx->rom())->directAccess(paletteAddr)); + oxRequire(pal, static_cast(ctx->rom()).directAccess(paletteAddr)); oxReturnError(ox::readMC(pal, palStat.size, &target)); return {}; } diff --git a/src/nostalgia/core/opengl/CMakeLists.txt b/src/nostalgia/core/opengl/CMakeLists.txt index 9c387c8c..48a0e7fb 100644 --- a/src/nostalgia/core/opengl/CMakeLists.txt +++ b/src/nostalgia/core/opengl/CMakeLists.txt @@ -1,7 +1,6 @@ target_sources( NostalgiaCore PRIVATE context.cpp - core.cpp gfx.cpp ) target_link_libraries( diff --git a/src/nostalgia/core/opengl/context.cpp b/src/nostalgia/core/opengl/context.cpp index 62a97601..11bdaec0 100644 --- a/src/nostalgia/core/opengl/context.cpp +++ b/src/nostalgia/core/opengl/context.cpp @@ -11,4 +11,11 @@ GlContext::~GlContext() noexcept { shutdownGfx(this); } +ox::Result> init(turbine::Context *tctx, const InitParams ¶ms) noexcept { + ox::UPtr ctx = ox::make_unique(); + ctx->turbineCtx = tctx; + oxReturnError(initGfx(ctx.get(), params)); + return ctx; +} + } diff --git a/src/nostalgia/core/opengl/core.cpp b/src/nostalgia/core/opengl/core.cpp deleted file mode 100644 index 62f82717..00000000 --- a/src/nostalgia/core/opengl/core.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. - */ - -#include -#include - -#include - -#include "context.hpp" - -namespace nostalgia::core { - -ox::Result> init(turbine::Context *tctx, const InitParams ¶ms) noexcept { - ox::UPtr ctx = ox::make_unique(); - ctx->turbineCtx = tctx; - oxReturnError(initGfx(ctx.get(), params)); - return ctx; -} - -} \ No newline at end of file diff --git a/src/nostalgia/scene/studio/sceneeditor-imgui.cpp b/src/nostalgia/scene/studio/sceneeditor-imgui.cpp index 0d5502d0..972494fa 100644 --- a/src/nostalgia/scene/studio/sceneeditor-imgui.cpp +++ b/src/nostalgia/scene/studio/sceneeditor-imgui.cpp @@ -6,8 +6,6 @@ #include -#include - #include "sceneeditor-imgui.hpp" namespace nostalgia::scene { diff --git a/src/nostalgia/scene/studio/sceneeditor-imgui.hpp b/src/nostalgia/scene/studio/sceneeditor-imgui.hpp index 9cbb4ddd..848ced19 100644 --- a/src/nostalgia/scene/studio/sceneeditor-imgui.hpp +++ b/src/nostalgia/scene/studio/sceneeditor-imgui.hpp @@ -6,7 +6,7 @@ #include -#include +#include #include "sceneeditor.hpp" #include "sceneeditorview.hpp" diff --git a/src/nostalgia/scene/studio/sceneeditor.cpp b/src/nostalgia/scene/studio/sceneeditor.cpp index 0b88534e..0333e1ca 100644 --- a/src/nostalgia/scene/studio/sceneeditor.cpp +++ b/src/nostalgia/scene/studio/sceneeditor.cpp @@ -2,6 +2,8 @@ * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ +#include + #include "sceneeditor.hpp" namespace nostalgia::scene { diff --git a/src/nostalgia/scene/studio/sceneeditor.hpp b/src/nostalgia/scene/studio/sceneeditor.hpp index 3df3b59d..6d1a2e30 100644 --- a/src/nostalgia/scene/studio/sceneeditor.hpp +++ b/src/nostalgia/scene/studio/sceneeditor.hpp @@ -4,9 +4,8 @@ #pragma once -#include +#include -#include #include namespace nostalgia::scene { diff --git a/src/nostalgia/scene/studio/sceneeditorview.cpp b/src/nostalgia/scene/studio/sceneeditorview.cpp index cd253ea7..f802c4eb 100644 --- a/src/nostalgia/scene/studio/sceneeditorview.cpp +++ b/src/nostalgia/scene/studio/sceneeditorview.cpp @@ -2,7 +2,7 @@ * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ -#include +#include #include "sceneeditorview.hpp" @@ -22,7 +22,7 @@ void SceneEditorView::draw(int width, int height) noexcept { if (width != m_frameBuffer.width || height != m_frameBuffer.height) { glutils::resizeInitFrameBuffer(&m_frameBuffer, width, height); } - glutils::FrameBufferBind frameBufferBind(m_frameBuffer); + const glutils::FrameBufferBind frameBufferBind(m_frameBuffer); core::gl::drawMainView(m_cctx.get(), {width, height}); } diff --git a/src/nostalgia/scene/studio/sceneeditorview.hpp b/src/nostalgia/scene/studio/sceneeditorview.hpp index 1c6f3af5..19653d15 100644 --- a/src/nostalgia/scene/studio/sceneeditorview.hpp +++ b/src/nostalgia/scene/studio/sceneeditorview.hpp @@ -6,7 +6,7 @@ #include -#include +#include #include namespace nostalgia::scene { diff --git a/src/nostalgia/scene/studio/studiomodule.hpp b/src/nostalgia/scene/studio/studiomodule.hpp index 0d83e3ed..3fb77e73 100644 --- a/src/nostalgia/scene/studio/studiomodule.hpp +++ b/src/nostalgia/scene/studio/studiomodule.hpp @@ -4,7 +4,6 @@ #pragma once -#include #include namespace nostalgia::scene {