diff --git a/src/nostalgia/core/context.cpp b/src/nostalgia/core/context.cpp index 802dafea..a0b5af84 100644 --- a/src/nostalgia/core/context.cpp +++ b/src/nostalgia/core/context.cpp @@ -1,16 +1,3 @@ /* * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ - -#include "context.hpp" -#include "gfx.hpp" - -#include "core.hpp" - -namespace nostalgia::core { - -Context::~Context() noexcept { - shutdownGfx(this); -} - -} diff --git a/src/nostalgia/core/context.hpp b/src/nostalgia/core/context.hpp index 72e1640f..762899b6 100644 --- a/src/nostalgia/core/context.hpp +++ b/src/nostalgia/core/context.hpp @@ -14,62 +14,19 @@ #include "initparams.hpp" -namespace nostalgia::core { -class Context; -} - -namespace nostalgia::core::gl { -void drawMainView(core::Context*, ox::Size const&) noexcept; -void drawMainView(core::Context*) noexcept; -} - namespace nostalgia::core { // User Input Output class Context { - friend bool bgStatus(Context *ctx, unsigned bg) noexcept; - friend ox::Error initGfx(Context *ctx, const InitParams&) noexcept; - friend void shutdownGfx(Context *ctx) noexcept; - friend ox::Error loadBgTileSheet(Context *ctx, - unsigned cbb, - const ox::FileAddress &tilesheetPath, - const ox::FileAddress &palettePath) noexcept; - friend ox::Error loadSpriteTileSheet(Context *ctx, - const ox::FileAddress &tilesheetAddr, - const ox::FileAddress &paletteAddr) noexcept; - friend ox::Result loadTileSheet(Context *ctx, - const struct CompactTileSheet &tilesheetAddr) noexcept; - friend uint8_t bgStatus(Context *ctx) noexcept; - friend void clearTileLayer(Context *ctx, unsigned bgIdx) noexcept; - friend void draw(Context *ctx) noexcept; - friend void setBgCbb(Context *ctx, unsigned bgIdx, unsigned cbb) noexcept; - friend void setBgStatus(Context *ctx, uint32_t status) noexcept; - friend void setBgStatus(Context *ctx, unsigned bg, bool status) noexcept; - friend void setTile(Context *ctx, unsigned bgIdx, int column, int row, uint8_t tile) noexcept; - friend void setSprite(Context *ctx, - unsigned idx, - int x, - int y, - unsigned tileIdx, - unsigned spriteShape, - unsigned spriteSize, - unsigned flipX) noexcept; - friend void hideSprite(Context *ctx, unsigned idx) noexcept; - friend void gl::drawMainView(core::Context*, ox::Size const&) noexcept; - friend void gl::drawMainView(core::Context*) noexcept; public: turbine::Context *turbineCtx = nullptr; - public: Context() noexcept = default; - Context(Context &other) noexcept = delete; Context(const Context &other) noexcept = delete; Context(const Context &&other) noexcept = delete; - ~Context() noexcept; - auto &rom() noexcept { return *turbineCtx->rom; } diff --git a/src/nostalgia/core/gfx.hpp b/src/nostalgia/core/gfx.hpp index 0620337d..7a59e33f 100644 --- a/src/nostalgia/core/gfx.hpp +++ b/src/nostalgia/core/gfx.hpp @@ -81,3 +81,9 @@ void setSprite(Context *ctx, unsigned idx, int x, int y, unsigned tileIdx, void setSprite(Context *ctx, const Sprite &s) noexcept; } + +namespace nostalgia::core::gl { +void drawMainView(core::Context*, ox::Size const&) noexcept; +void drawMainView(core::Context*) noexcept; +} + diff --git a/src/nostalgia/core/opengl/CMakeLists.txt b/src/nostalgia/core/opengl/CMakeLists.txt index 7cf0929a..9c387c8c 100644 --- a/src/nostalgia/core/opengl/CMakeLists.txt +++ b/src/nostalgia/core/opengl/CMakeLists.txt @@ -1,5 +1,6 @@ target_sources( NostalgiaCore PRIVATE + context.cpp core.cpp gfx.cpp ) diff --git a/src/nostalgia/core/opengl/context.cpp b/src/nostalgia/core/opengl/context.cpp new file mode 100644 index 00000000..62a97601 --- /dev/null +++ b/src/nostalgia/core/opengl/context.cpp @@ -0,0 +1,14 @@ +/* + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#include "context.hpp" +#include "gfx.hpp" + +namespace nostalgia::core { + +GlContext::~GlContext() noexcept { + shutdownGfx(this); +} + +} diff --git a/src/nostalgia/core/opengl/context.hpp b/src/nostalgia/core/opengl/context.hpp index 360e6f98..e695f22f 100644 --- a/src/nostalgia/core/opengl/context.hpp +++ b/src/nostalgia/core/opengl/context.hpp @@ -10,6 +10,9 @@ #include "gfx.hpp" +#include "../gfx.hpp" +#include "../context.hpp" + namespace nostalgia::core { struct GlContext: public core::Context { @@ -21,6 +24,7 @@ struct GlContext: public core::Context { ox::Array backgrounds; ox::Optional renderSize; renderer::Drawer drawer; + ~GlContext() noexcept; }; } diff --git a/src/nostalgia/core/opengl/gfx.hpp b/src/nostalgia/core/opengl/gfx.hpp index b5c26f2d..43a7609e 100644 --- a/src/nostalgia/core/opengl/gfx.hpp +++ b/src/nostalgia/core/opengl/gfx.hpp @@ -10,6 +10,8 @@ #include +#include "../context.hpp" + namespace nostalgia::core::renderer { constexpr uint64_t TileRows = 128; @@ -59,5 +61,6 @@ class Drawer: public turbine::gl::Drawer { } namespace nostalgia::core { -ox::Error initGfx(Context *ctx, const InitParams &) noexcept; +ox::Error initGfx(Context *ctx, const InitParams&) noexcept; +void shutdownGfx(Context *ctx) noexcept; } \ No newline at end of file