[nostalgia/core] Delete all of core::Context's friendships

This commit is contained in:
Gary Talent 2023-06-03 21:17:11 -05:00
parent 7d0dcae00e
commit 5dd3b678ae
7 changed files with 29 additions and 57 deletions

View File

@ -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);
}
}

View File

@ -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<struct TileSheetData> 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;
}

View File

@ -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;
}

View File

@ -1,5 +1,6 @@
target_sources(
NostalgiaCore PRIVATE
context.cpp
core.cpp
gfx.cpp
)

View File

@ -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);
}
}

View File

@ -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<renderer::Background, 4> backgrounds;
ox::Optional<ox::Size> renderSize;
renderer::Drawer drawer;
~GlContext() noexcept;
};
}

View File

@ -10,6 +10,8 @@
#include <glutils/glutils.hpp>
#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;
}