From 5dd3b678ae98c91c70d7129ffdd82d1958a8859e Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 3 Jun 2023 21:17:11 -0500 Subject: [PATCH] [nostalgia/core] Delete all of core::Context's friendships --- src/nostalgia/core/context.cpp | 13 ------- src/nostalgia/core/context.hpp | 43 ------------------------ src/nostalgia/core/gfx.hpp | 6 ++++ src/nostalgia/core/opengl/CMakeLists.txt | 1 + src/nostalgia/core/opengl/context.cpp | 14 ++++++++ src/nostalgia/core/opengl/context.hpp | 4 +++ src/nostalgia/core/opengl/gfx.hpp | 5 ++- 7 files changed, 29 insertions(+), 57 deletions(-) create mode 100644 src/nostalgia/core/opengl/context.cpp diff --git a/src/nostalgia/core/context.cpp b/src/nostalgia/core/context.cpp index 802dafea7..a0b5af844 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 72e1640f8..762899b6e 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 0620337d6..7a59e33ff 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 7cf0929ae..9c387c8cc 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 000000000..62a97601e --- /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 360e6f980..e695f22fb 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 b5c26f2d3..43a7609e7 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