Compare commits

...

2 Commits

Author SHA1 Message Date
672b92b363 [nostalgia/gfx/studio] Remove accidental version tag in default Palette
All checks were successful
Build / build (push) Successful in 3m23s
2025-01-20 03:13:01 -06:00
762a6517b2 [nostalgia] Rename core to gfx 2025-01-20 03:11:35 -06:00
98 changed files with 214 additions and 214 deletions

View File

@ -1,6 +1,6 @@
# module dir list # module dir list
add_subdirectory(core) add_subdirectory(gfx)
add_subdirectory(scene) add_subdirectory(scene)
# module libraries # module libraries

View File

@ -7,7 +7,7 @@
#include <ox/std/math.hpp> #include <ox/std/math.hpp>
#include <ox/std/types.hpp> #include <ox/std/types.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
using Color16 = uint16_t; using Color16 = uint16_t;
@ -154,7 +154,7 @@ static_assert(color16(16, 32, 8) == 9200);
[[nodiscard]] [[nodiscard]]
constexpr Color16 applySelectionColor(Color16 const color) noexcept { constexpr Color16 applySelectionColor(Color16 const color) noexcept {
namespace core = nostalgia::core; namespace core = nostalgia::gfx;
auto const r = core::red16(color) / 2; auto const r = core::red16(color) / 2;
auto const g = (core::green16(color) + 20) / 2; auto const g = (core::green16(color) + 20) / 2;
auto const b = (core::blue16(color) + 31) / 2; auto const b = (core::blue16(color) + 31) / 2;

View File

@ -6,7 +6,7 @@
#include <ox/std/stringliteral.hpp> #include <ox/std/stringliteral.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
constexpr auto TileWidth = 8; constexpr auto TileWidth = 8;
constexpr auto TileHeight = 8; constexpr auto TileHeight = 8;

View File

@ -13,7 +13,7 @@
#include "initparams.hpp" #include "initparams.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
class Context; class Context;

View File

@ -13,7 +13,7 @@
#include "palette.hpp" #include "palette.hpp"
#include "tilesheet.hpp" #include "tilesheet.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
struct Sprite { struct Sprite {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Sprite"; static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Sprite";
@ -242,15 +242,15 @@ void puts(Context &ctx, int column, int row, ox::StringViewCR str) noexcept;
} }
namespace nostalgia::core::gl { namespace nostalgia::gfx::gl {
constexpr ox::CStringView GlslVersion = "#version 330"; constexpr ox::CStringView GlslVersion = "#version 330";
[[nodiscard]] [[nodiscard]]
ox::Size drawSize(int scale = 5) noexcept; ox::Size drawSize(int scale = 5) noexcept;
void draw(core::Context &ctx, ox::Size const&renderSz) noexcept; void draw(gfx::Context &ctx, ox::Size const&renderSz) noexcept;
void draw(core::Context&, int scale = 5) noexcept; void draw(gfx::Context&, int scale = 5) noexcept;
} }

View File

@ -6,7 +6,7 @@
#include <ox/std/types.hpp> #include <ox/std/types.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
struct InitParams { struct InitParams {
bool glInstallDrawer = true; bool glInstallDrawer = true;

View File

@ -6,7 +6,7 @@
#include <keel/module.hpp> #include <keel/module.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
const keel::Module *keelModule() noexcept; const keel::Module *keelModule() noexcept;

View File

@ -11,7 +11,7 @@
#include "color.hpp" #include "color.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
struct PaletteColorV1 { struct PaletteColorV1 {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.PaletteColor"; static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.PaletteColor";

View File

@ -8,7 +8,7 @@
#include "consts.hpp" #include "consts.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
[[nodiscard]] [[nodiscard]]
constexpr std::size_t ptToIdx(int x, int y, int c, int scale = 1) noexcept { constexpr std::size_t ptToIdx(int x, int y, int c, int scale = 1) noexcept {

View File

@ -6,7 +6,7 @@
#include <studio/studio.hpp> #include <studio/studio.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
const studio::Module *studioModule() noexcept; const studio::Module *studioModule() noexcept;

View File

@ -12,11 +12,11 @@
#include <ox/std/types.hpp> #include <ox/std/types.hpp>
#include <ox/model/def.hpp> #include <ox/model/def.hpp>
#include <nostalgia/core/ptidxconv.hpp> #include <nostalgia/gfx/ptidxconv.hpp>
#include "palette.hpp" #include "palette.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
struct SubSheetTemplate { struct SubSheetTemplate {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.SubSheetTemplate"; static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.SubSheetTemplate";

View File

@ -4,11 +4,11 @@
#include <turbine/turbine.hpp> #include <turbine/turbine.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include "context.hpp" #include "context.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
void safeDelete(Context *ctx) noexcept { void safeDelete(Context *ctx) noexcept {
delete ctx; delete ctx;

View File

@ -4,9 +4,9 @@
#pragma once #pragma once
#include <nostalgia/core/context.hpp> #include <nostalgia/gfx/context.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
struct BgCbbData { struct BgCbbData {
unsigned bpp = 4; unsigned bpp = 4;

View File

@ -11,15 +11,15 @@
#include <keel/keel.hpp> #include <keel/keel.hpp>
#include <nostalgia/core/context.hpp> #include <nostalgia/gfx/context.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include <nostalgia/core/tilesheet.hpp> #include <nostalgia/gfx/tilesheet.hpp>
#include "context.hpp" #include "context.hpp"
OX_ALLOW_UNSAFE_BUFFERS_BEGIN OX_ALLOW_UNSAFE_BUFFERS_BEGIN
namespace nostalgia::core { namespace nostalgia::gfx {
static constexpr auto SpriteCount = 128; static constexpr auto SpriteCount = 128;

View File

@ -4,8 +4,8 @@
#pragma once #pragma once
#include <nostalgia/core/context.hpp> #include <nostalgia/gfx/context.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
ox::Error initGfx(Context &ctx, InitParams const&) noexcept; ox::Error initGfx(Context &ctx, InitParams const&) noexcept;
} }

View File

@ -12,7 +12,7 @@
#include <teagba/addresses.hpp> #include <teagba/addresses.hpp>
#include <teagba/bios.hpp> #include <teagba/bios.hpp>
#include <nostalgia/core/core.hpp> #include <nostalgia/gfx/core.hpp>
#include "gfx.hpp" #include "gfx.hpp"
@ -22,7 +22,7 @@
namespace ox { namespace ox {
using namespace nostalgia::core; using namespace nostalgia::gfx;
void panic(const char *file, int line, const char *panicMsg, ox::Error const&err) noexcept { void panic(const char *file, int line, const char *panicMsg, ox::Error const&err) noexcept {
// reset heap to make sure we have enough memory to allocate context data // reset heap to make sure we have enough memory to allocate context data

View File

@ -3,9 +3,9 @@
*/ */
#include <keel/media.hpp> #include <keel/media.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
constexpr auto GbaTileColumns = 32; constexpr auto GbaTileColumns = 32;
constexpr auto GbaTileRows = 32; constexpr auto GbaTileRows = 32;

View File

@ -7,12 +7,12 @@
#include <keel/asset.hpp> #include <keel/asset.hpp>
#include <keel/module.hpp> #include <keel/module.hpp>
#include <nostalgia/core/palette.hpp> #include <nostalgia/gfx/palette.hpp>
#include <nostalgia/core/tilesheet.hpp> #include <nostalgia/gfx/tilesheet.hpp>
#include "typeconv.hpp" #include "typeconv.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
static class: public keel::Module { static class: public keel::Module {
private: private:

View File

@ -4,7 +4,7 @@
#include "typeconv.hpp" #include "typeconv.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
ox::Error NostalgiaPaletteToPaletteV1Converter::convert( ox::Error NostalgiaPaletteToPaletteV1Converter::convert(
keel::Context&, keel::Context&,

View File

@ -8,11 +8,11 @@
#include <keel/typeconv.hpp> #include <keel/typeconv.hpp>
#include <nostalgia/core/context.hpp> #include <nostalgia/gfx/context.hpp>
#include <nostalgia/core/palette.hpp> #include <nostalgia/gfx/palette.hpp>
#include <nostalgia/core/tilesheet.hpp> #include <nostalgia/gfx/tilesheet.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
// Type converters // Type converters

View File

@ -5,7 +5,7 @@
#include "context.hpp" #include "context.hpp"
#include "gfx.hpp" #include "gfx.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
void safeDelete(Context *ctx) noexcept { void safeDelete(Context *ctx) noexcept {
delete ctx; delete ctx;

View File

@ -8,12 +8,12 @@
#include <glutils/glutils.hpp> #include <glutils/glutils.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include <nostalgia/core/context.hpp> #include <nostalgia/gfx/context.hpp>
#include "gfx.hpp" #include "gfx.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
class Context { class Context {

View File

@ -10,15 +10,15 @@
#include <glutils/glutils.hpp> #include <glutils/glutils.hpp>
#include <nostalgia/core/context.hpp> #include <nostalgia/gfx/context.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include <nostalgia/core/palette.hpp> #include <nostalgia/gfx/palette.hpp>
#include <nostalgia/core/tilesheet.hpp> #include <nostalgia/gfx/tilesheet.hpp>
#include "context.hpp" #include "context.hpp"
#include "gfx.hpp" #include "gfx.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
namespace renderer { namespace renderer {
@ -28,7 +28,7 @@ static constexpr auto PriorityScale = 0.01f;
Drawer::Drawer(Context &ctx) noexcept: m_ctx(ctx) {} Drawer::Drawer(Context &ctx) noexcept: m_ctx(ctx) {}
void Drawer::draw(turbine::Context &tctx) noexcept { void Drawer::draw(turbine::Context &tctx) noexcept {
core::gl::draw(m_ctx, turbine::getScreenSize(tctx)); gfx::gl::draw(m_ctx, turbine::getScreenSize(tctx));
} }
static constexpr ox::CStringView bgvshadTmpl = R"glsl( static constexpr ox::CStringView bgvshadTmpl = R"glsl(
@ -768,7 +768,7 @@ ox::Size drawSize(int scale) noexcept {
return {240 * scale, 160 * scale}; return {240 * scale, 160 * scale};
} }
void draw(core::Context &ctx, ox::Size const&renderSz) noexcept { void draw(gfx::Context &ctx, ox::Size const&renderSz) noexcept {
glViewport(0, 0, renderSz.width, renderSz.height); glViewport(0, 0, renderSz.width, renderSz.height);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND); glEnable(GL_BLEND);
@ -783,7 +783,7 @@ void draw(core::Context &ctx, ox::Size const&renderSz) noexcept {
glDisable(GL_BLEND); glDisable(GL_BLEND);
} }
void draw(core::Context &ctx, int scale) noexcept { void draw(gfx::Context &ctx, int scale) noexcept {
draw(ctx, drawSize(scale)); draw(ctx, drawSize(scale));
} }

View File

@ -10,9 +10,9 @@
#include <glutils/glutils.hpp> #include <glutils/glutils.hpp>
#include <nostalgia/core/context.hpp> #include <nostalgia/gfx/context.hpp>
namespace nostalgia::core::renderer { namespace nostalgia::gfx::renderer {
constexpr uint64_t TileRows = 128; constexpr uint64_t TileRows = 128;
constexpr uint64_t TileColumns = 128; constexpr uint64_t TileColumns = 128;
@ -59,7 +59,7 @@ class Drawer: public turbine::gl::Drawer {
} }
namespace nostalgia::core { namespace nostalgia::gfx {
ox::Error initGfx(Context &ctx, InitParams const&) noexcept; ox::Error initGfx(Context &ctx, InitParams const&) noexcept;
void shutdownGfx(Context &ctx) noexcept; void shutdownGfx(Context &ctx) noexcept;
} }

View File

@ -5,7 +5,7 @@
#include "commands.hpp" #include "commands.hpp"
#include "addcolorcommand.hpp" #include "addcolorcommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
AddColorCommand::AddColorCommand(Palette &pal, Color16 const color, size_t const idx) noexcept: AddColorCommand::AddColorCommand(Palette &pal, Color16 const color, size_t const idx) noexcept:
m_pal(pal), m_pal(pal),

View File

@ -6,9 +6,9 @@
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp> #include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
class AddColorCommand: public studio::UndoCommand { class AddColorCommand: public studio::UndoCommand {
private: private:

View File

@ -6,7 +6,7 @@
#include "addpagecommand.hpp" #include "addpagecommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
AddPageCommand::AddPageCommand(Palette &pal) noexcept: AddPageCommand::AddPageCommand(Palette &pal) noexcept:
m_pal(pal) {} m_pal(pal) {}

View File

@ -6,9 +6,9 @@
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp> #include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
class AddPageCommand: public studio::UndoCommand { class AddPageCommand: public studio::UndoCommand {
private: private:

View File

@ -5,7 +5,7 @@
#include "commands.hpp" #include "commands.hpp"
#include "applycolorallpagescommand.hpp" #include "applycolorallpagescommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
ApplyColorAllPagesCommand::ApplyColorAllPagesCommand(Palette &pal, size_t const page, size_t const idx): ApplyColorAllPagesCommand::ApplyColorAllPagesCommand(Palette &pal, size_t const page, size_t const idx):
m_pal(pal), m_pal(pal),

View File

@ -6,9 +6,9 @@
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp> #include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
class ApplyColorAllPagesCommand: public studio::UndoCommand { class ApplyColorAllPagesCommand: public studio::UndoCommand {
private: private:

View File

@ -4,7 +4,7 @@
#pragma once #pragma once
namespace nostalgia::core { namespace nostalgia::gfx {
enum class PaletteEditorCommandId { enum class PaletteEditorCommandId {
ApplyColorAllPages, ApplyColorAllPages,

View File

@ -6,7 +6,7 @@
#include "duplicatepagecommand.hpp" #include "duplicatepagecommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
DuplicatePageCommand::DuplicatePageCommand(Palette &pal, size_t srcIdx, size_t dstIdx) noexcept: DuplicatePageCommand::DuplicatePageCommand(Palette &pal, size_t srcIdx, size_t dstIdx) noexcept:
m_pal(pal), m_pal(pal),

View File

@ -6,9 +6,9 @@
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp> #include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
class DuplicatePageCommand: public studio::UndoCommand { class DuplicatePageCommand: public studio::UndoCommand {
private: private:

View File

@ -6,7 +6,7 @@
#include "movecolorcommand.hpp" #include "movecolorcommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
MoveColorCommand::MoveColorCommand( MoveColorCommand::MoveColorCommand(
Palette &pal, size_t page, size_t srcIdx, size_t dstIdx) noexcept: Palette &pal, size_t page, size_t srcIdx, size_t dstIdx) noexcept:

View File

@ -6,9 +6,9 @@
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp> #include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
class MoveColorCommand: public studio::UndoCommand { class MoveColorCommand: public studio::UndoCommand {
private: private:

View File

@ -5,7 +5,7 @@
#include "commands.hpp" #include "commands.hpp"
#include "removecolorcommand.hpp" #include "removecolorcommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
RemoveColorCommand::RemoveColorCommand(Palette &pal, size_t const idx) noexcept: RemoveColorCommand::RemoveColorCommand(Palette &pal, size_t const idx) noexcept:
m_pal(pal), m_pal(pal),

View File

@ -6,9 +6,9 @@
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp> #include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
class RemoveColorCommand: public studio::UndoCommand { class RemoveColorCommand: public studio::UndoCommand {
private: private:

View File

@ -6,7 +6,7 @@
#include "removepagecommand.hpp" #include "removepagecommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
RemovePageCommand::RemovePageCommand(Palette &pal, size_t idx) noexcept: RemovePageCommand::RemovePageCommand(Palette &pal, size_t idx) noexcept:
m_pal(pal), m_pal(pal),

View File

@ -6,9 +6,9 @@
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp> #include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
class RemovePageCommand: public studio::UndoCommand { class RemovePageCommand: public studio::UndoCommand {
private: private:

View File

@ -4,7 +4,7 @@
#include "renamepagecommand.hpp" #include "renamepagecommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
RenamePageCommand::RenamePageCommand(Palette &pal, size_t const page, ox::StringParam name) noexcept: RenamePageCommand::RenamePageCommand(Palette &pal, size_t const page, ox::StringParam name) noexcept:
m_pal(pal), m_pal(pal),

View File

@ -6,11 +6,11 @@
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp> #include <nostalgia/gfx/palette.hpp>
#include "commands.hpp" #include "commands.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
class RenamePageCommand: public studio::UndoCommand { class RenamePageCommand: public studio::UndoCommand {
private: private:

View File

@ -5,7 +5,7 @@
#include "commands.hpp" #include "commands.hpp"
#include "updatecolorcommand.hpp" #include "updatecolorcommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
UpdateColorCommand::UpdateColorCommand( UpdateColorCommand::UpdateColorCommand(
Palette &pal, Palette &pal,

View File

@ -6,9 +6,9 @@
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp> #include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
class UpdateColorCommand: public studio::UndoCommand { class UpdateColorCommand: public studio::UndoCommand {
private: private:

View File

@ -5,7 +5,7 @@
#include "commands.hpp" #include "commands.hpp"
#include "updatecolorinfocommand.hpp" #include "updatecolorinfocommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
UpdateColorInfoCommand::UpdateColorInfoCommand( UpdateColorInfoCommand::UpdateColorInfoCommand(
Palette &pal, Palette &pal,

View File

@ -6,9 +6,9 @@
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp> #include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
class UpdateColorInfoCommand: public studio::UndoCommand { class UpdateColorInfoCommand: public studio::UndoCommand {
private: private:

View File

@ -19,7 +19,7 @@
#include "paletteeditor-imgui.hpp" #include "paletteeditor-imgui.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
namespace ig = studio::ig; namespace ig = studio::ig;

View File

@ -6,10 +6,10 @@
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include <nostalgia/core/palette.hpp> #include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
class PaletteEditorImGui: public studio::Editor { class PaletteEditorImGui: public studio::Editor {

View File

@ -9,7 +9,7 @@
#include "paletteeditor/paletteeditor-imgui.hpp" #include "paletteeditor/paletteeditor-imgui.hpp"
#include "tilesheeteditor/tilesheeteditor-imgui.hpp" #include "tilesheeteditor/tilesheeteditor-imgui.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
static class: public studio::Module { static class: public studio::Module {
ox::Vector<studio::EditorMaker> editors(studio::StudioContext &ctx) const noexcept final { ox::Vector<studio::EditorMaker> editors(studio::StudioContext &ctx) const noexcept final {
@ -24,7 +24,7 @@ static class: public studio::Module {
out.emplace_back(ox::make<studio::ItemMakerT<TileSheet>>("Tile Sheet", "TileSheets", FileExt_ng)); out.emplace_back(ox::make<studio::ItemMakerT<TileSheet>>("Tile Sheet", "TileSheets", FileExt_ng));
out.emplace_back(ox::make<studio::ItemMakerT<Palette>>("Palette", "Palettes", FileExt_npal, Palette{ out.emplace_back(ox::make<studio::ItemMakerT<Palette>>("Palette", "Palettes", FileExt_npal, Palette{
.colorNames = {}, .colorNames = {},
.pages = {{"Page 1", ox::Vector<PaletteColorV1>{}}}, .pages = {{"Page 1", ox::Vector<PaletteColor>{}}},
}, ox::ClawFormat::Organic)); }, ox::ClawFormat::Organic));
return out; return out;
} }

View File

@ -4,7 +4,7 @@
#include "addsubsheetcommand.hpp" #include "addsubsheetcommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
AddSubSheetCommand::AddSubSheetCommand( AddSubSheetCommand::AddSubSheetCommand(
TileSheet &img, TileSheet &img,

View File

@ -6,7 +6,7 @@
#include "commands.hpp" #include "commands.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
class AddSubSheetCommand: public TileSheetCommand { class AddSubSheetCommand: public TileSheetCommand {
private: private:

View File

@ -5,9 +5,9 @@
#pragma once #pragma once
#include <studio/undostack.hpp> #include <studio/undostack.hpp>
#include <nostalgia/core/tilesheet.hpp> #include <nostalgia/gfx/tilesheet.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
// Command IDs to use with QUndoCommand::id() // Command IDs to use with QUndoCommand::id()
enum class CommandId { enum class CommandId {

View File

@ -4,7 +4,7 @@
#include "cutpastecommand.hpp" #include "cutpastecommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
TileSheetClipboard::Pixel::Pixel(uint16_t pColorIdx, ox::Point pPt) noexcept { TileSheetClipboard::Pixel::Pixel(uint16_t pColorIdx, ox::Point pPt) noexcept {
colorIdx = pColorIdx; colorIdx = pColorIdx;
@ -37,7 +37,7 @@ CutPasteCommand::CutPasteCommand(
for (auto const&p : cb.pixels()) { for (auto const&p : cb.pixels()) {
auto const dstPt = p.pt + dstStart; auto const dstPt = p.pt + dstStart;
if (dstPt.x <= dstEnd.x && dstPt.y <= dstEnd.y) { if (dstPt.x <= dstEnd.x && dstPt.y <= dstEnd.y) {
auto const idx = core::idx(ss, dstPt); auto const idx = gfx::idx(ss, dstPt);
m_changes.emplace_back(static_cast<uint32_t>(idx), p.colorIdx, getPixel(ss, m_img.bpp, idx)); m_changes.emplace_back(static_cast<uint32_t>(idx), p.colorIdx, getPixel(ss, m_img.bpp, idx));
} }
} }

View File

@ -8,7 +8,7 @@
#include "commands.hpp" #include "commands.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
OX_MODEL_FWD_DECL(class TileSheetClipboard); OX_MODEL_FWD_DECL(class TileSheetClipboard);

View File

@ -6,9 +6,9 @@
#include "deletetilescommand.hpp" #include "deletetilescommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
core::DeleteTilesCommand::DeleteTilesCommand( gfx::DeleteTilesCommand::DeleteTilesCommand(
TileSheet &img, TileSheet &img,
TileSheet::SubSheetIdx idx, TileSheet::SubSheetIdx idx,
std::size_t tileIdx, std::size_t tileIdx,
@ -28,7 +28,7 @@ core::DeleteTilesCommand::DeleteTilesCommand(
} }
} }
ox::Error core::DeleteTilesCommand::redo() noexcept { ox::Error gfx::DeleteTilesCommand::redo() noexcept {
auto &s = getSubSheet(m_img, m_idx); auto &s = getSubSheet(m_img, m_idx);
auto &p = s.pixels; auto &p = s.pixels;
auto srcPos = m_deletePos + m_deleteSz; auto srcPos = m_deletePos + m_deleteSz;

View File

@ -6,7 +6,7 @@
#include "commands.hpp" #include "commands.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
class DeleteTilesCommand: public TileSheetCommand { class DeleteTilesCommand: public TileSheetCommand {
private: private:

View File

@ -4,7 +4,7 @@
#include "drawcommand.hpp" #include "drawcommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
DrawCommand::DrawCommand( DrawCommand::DrawCommand(
TileSheet &img, TileSheet &img,

View File

@ -6,7 +6,7 @@
#include "commands.hpp" #include "commands.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
class DrawCommand: public TileSheetCommand { class DrawCommand: public TileSheetCommand {
private: private:

View File

@ -4,7 +4,7 @@
#include "inserttilescommand.hpp" #include "inserttilescommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
InsertTilesCommand::InsertTilesCommand( InsertTilesCommand::InsertTilesCommand(
TileSheet &img, TileSheet &img,

View File

@ -6,7 +6,7 @@
#include "commands.hpp" #include "commands.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
class InsertTilesCommand: public TileSheetCommand { class InsertTilesCommand: public TileSheetCommand {
private: private:

View File

@ -4,9 +4,9 @@
#include "palettechangecommand.hpp" #include "palettechangecommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
core::PaletteChangeCommand::PaletteChangeCommand( gfx::PaletteChangeCommand::PaletteChangeCommand(
TileSheet::SubSheetIdx idx, TileSheet::SubSheetIdx idx,
TileSheet &img, TileSheet &img,
ox::StringViewCR newPalette) noexcept: ox::StringViewCR newPalette) noexcept:

View File

@ -6,7 +6,7 @@
#include "commands.hpp" #include "commands.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
class PaletteChangeCommand: public TileSheetCommand { class PaletteChangeCommand: public TileSheetCommand {
private: private:

View File

@ -4,9 +4,9 @@
#include "rmsubsheetcommand.hpp" #include "rmsubsheetcommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
core::RmSubSheetCommand::RmSubSheetCommand(TileSheet &img, TileSheet::SubSheetIdx idx) noexcept: gfx::RmSubSheetCommand::RmSubSheetCommand(TileSheet &img, TileSheet::SubSheetIdx idx) noexcept:
m_img(img), m_img(img),
m_idx(std::move(idx)), m_idx(std::move(idx)),
m_parentIdx(m_idx) { m_parentIdx(m_idx) {

View File

@ -6,7 +6,7 @@
#include "commands.hpp" #include "commands.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
class RmSubSheetCommand: public TileSheetCommand { class RmSubSheetCommand: public TileSheetCommand {
private: private:

View File

@ -4,9 +4,9 @@
#include "updatesubsheetcommand.hpp" #include "updatesubsheetcommand.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
core::UpdateSubSheetCommand::UpdateSubSheetCommand( gfx::UpdateSubSheetCommand::UpdateSubSheetCommand(
TileSheet &img, TileSheet &img,
TileSheet::SubSheetIdx idx, TileSheet::SubSheetIdx idx,
ox::StringParam name, ox::StringParam name,

View File

@ -6,7 +6,7 @@
#include "commands.hpp" #include "commands.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
class UpdateSubSheetCommand: public TileSheetCommand { class UpdateSubSheetCommand: public TileSheetCommand {
private: private:

View File

@ -11,7 +11,7 @@
#include "tilesheeteditor-imgui.hpp" #include "tilesheeteditor-imgui.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
namespace ig = studio::ig; namespace ig = studio::ig;
@ -136,7 +136,7 @@ void TileSheetEditorImGui::keyStateChanged(turbine::Key key, bool down) {
auto const popupOpen = m_subsheetEditor.isOpen() || m_exportMenu.isOpen(); auto const popupOpen = m_subsheetEditor.isOpen() || m_exportMenu.isOpen();
auto const pal = m_model.pal(); auto const pal = m_model.pal();
if (!popupOpen) { if (!popupOpen) {
auto const colorCnt = core::colorCnt(pal, m_model.palettePage()); auto const colorCnt = gfx::colorCnt(pal, m_model.palettePage());
if (key == turbine::Key::Alpha_D) { if (key == turbine::Key::Alpha_D) {
m_tool = TileSheetTool::Draw; m_tool = TileSheetTool::Draw;
setCopyEnabled(false); setCopyEnabled(false);

View File

@ -14,7 +14,7 @@
#include "tilesheetpixels.hpp" #include "tilesheetpixels.hpp"
#include "tilesheeteditorview.hpp" #include "tilesheeteditorview.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
class TileSheetEditorImGui: public studio::Editor { class TileSheetEditorImGui: public studio::Editor {

View File

@ -11,7 +11,7 @@
#include <turbine/clipboard.hpp> #include <turbine/clipboard.hpp>
#include <keel/media.hpp> #include <keel/media.hpp>
#include <nostalgia/core/ptidxconv.hpp> #include <nostalgia/gfx/ptidxconv.hpp>
#include "commands/commands.hpp" #include "commands/commands.hpp"
#include "commands/addsubsheetcommand.hpp" #include "commands/addsubsheetcommand.hpp"
@ -24,7 +24,7 @@
#include "commands/updatesubsheetcommand.hpp" #include "commands/updatesubsheetcommand.hpp"
#include "tilesheeteditormodel.hpp" #include "tilesheeteditormodel.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
// delete pixels of all non-leaf nodes // delete pixels of all non-leaf nodes
static void normalizeSubsheets(TileSheet::SubSheet &ss) noexcept { static void normalizeSubsheets(TileSheet::SubSheet &ss) noexcept {
@ -66,7 +66,7 @@ void TileSheetEditorModel::cut() {
auto const&s = activeSubSheet(); auto const&s = activeSubSheet();
iterateSelectionRows(*m_selection, [&](int const x, int const y) { iterateSelectionRows(*m_selection, [&](int const x, int const y) {
auto pt = ox::Point{x, y}; auto pt = ox::Point{x, y};
auto const idx = core::idx(s, pt); auto const idx = gfx::idx(s, pt);
auto const c = getPixel(s, m_img.bpp, idx); auto const c = getPixel(s, m_img.bpp, idx);
pt -= m_selection->a; pt -= m_selection->a;
cb->addPixel(pt, c); cb->addPixel(pt, c);
@ -87,7 +87,7 @@ void TileSheetEditorModel::copy() {
iterateSelectionRows(*m_selection, [&](int const x, int const y) { iterateSelectionRows(*m_selection, [&](int const x, int const y) {
auto pt = ox::Point{x, y}; auto pt = ox::Point{x, y};
const auto&s = activeSubSheet(); const auto&s = activeSubSheet();
const auto idx = core::idx(s, pt); const auto idx = gfx::idx(s, pt);
const auto c = getPixel(s, m_img.bpp, idx); const auto c = getPixel(s, m_img.bpp, idx);
pt -= m_selection->a; pt -= m_selection->a;
cb->addPixel(pt, c); cb->addPixel(pt, c);
@ -156,7 +156,7 @@ void TileSheetEditorModel::drawCommand(ox::Point const&pt, std::size_t const pal
if (pt.x >= activeSubSheet.columns * TileWidth || pt.y >= activeSubSheet.rows * TileHeight) { if (pt.x >= activeSubSheet.columns * TileWidth || pt.y >= activeSubSheet.rows * TileHeight) {
return; return;
} }
const auto idx = core::idx(activeSubSheet, pt); const auto idx = gfx::idx(activeSubSheet, pt);
if (m_ongoingDrawCommand) { if (m_ongoingDrawCommand) {
m_updated = m_updated || m_ongoingDrawCommand->append(idx); m_updated = m_updated || m_ongoingDrawCommand->append(idx);
} else if (getPixel(activeSubSheet, m_img.bpp, idx) != palIdx) { } else if (getPixel(activeSubSheet, m_img.bpp, idx) != palIdx) {
@ -209,7 +209,7 @@ void TileSheetEditorModel::fill(ox::Point const&pt, int const palIdx) noexcept {
auto const oldColor = getPixel(activeSubSheet, m_img.bpp, pt); auto const oldColor = getPixel(activeSubSheet, m_img.bpp, pt);
getFillPixels(activeSubSheet, updateMap, pt, oldColor); getFillPixels(activeSubSheet, updateMap, pt, oldColor);
ox::Vector<std::size_t> idxList; ox::Vector<std::size_t> idxList;
auto i = core::idx(activeSubSheet, pt) / PixelsPerTile * PixelsPerTile; auto i = gfx::idx(activeSubSheet, pt) / PixelsPerTile * PixelsPerTile;
for (auto const u : updateMap) { for (auto const u : updateMap) {
if (u) { if (u) {
idxList.emplace_back(i); idxList.emplace_back(i);

View File

@ -9,10 +9,10 @@
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include <nostalgia/core/tilesheet.hpp> #include <nostalgia/gfx/tilesheet.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
class TileSheetEditorModel: public ox::SignalHandler { class TileSheetEditorModel: public ox::SignalHandler {

View File

@ -5,11 +5,11 @@
#include <ox/std/point.hpp> #include <ox/std/point.hpp>
#include <keel/media.hpp> #include <keel/media.hpp>
#include <nostalgia/core/consts.hpp> #include <nostalgia/gfx/consts.hpp>
#include "tilesheeteditorview.hpp" #include "tilesheeteditorview.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
TileSheetEditorView::TileSheetEditorView(studio::StudioContext &sctx, ox::StringView path, studio::UndoStack &undoStack): TileSheetEditorView::TileSheetEditorView(studio::StudioContext &sctx, ox::StringView path, studio::UndoStack &undoStack):
m_model(sctx, path, undoStack), m_model(sctx, path, undoStack),

View File

@ -10,13 +10,13 @@
#include <glutils/glutils.hpp> #include <glutils/glutils.hpp>
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include "tilesheeteditormodel.hpp" #include "tilesheeteditormodel.hpp"
#include "tilesheetpixelgrid.hpp" #include "tilesheetpixelgrid.hpp"
#include "tilesheetpixels.hpp" #include "tilesheetpixels.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
enum class TileSheetTool { enum class TileSheetTool {
None, None,

View File

@ -4,11 +4,11 @@
#include <ox/claw/write.hpp> #include <ox/claw/write.hpp>
#include <nostalgia/core/consts.hpp> #include <nostalgia/gfx/consts.hpp>
#include "tilesheetpixelgrid.hpp" #include "tilesheetpixelgrid.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
void TileSheetGrid::setPixelSizeMod(float sm) noexcept { void TileSheetGrid::setPixelSizeMod(float sm) noexcept {
m_pixelSizeMod = sm; m_pixelSizeMod = sm;

View File

@ -7,10 +7,10 @@
#include <glutils/glutils.hpp> #include <glutils/glutils.hpp>
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include <nostalgia/core/tilesheet.hpp> #include <nostalgia/gfx/tilesheet.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
class TileSheetGrid { class TileSheetGrid {

View File

@ -2,12 +2,12 @@
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/ */
#include <nostalgia/core/consts.hpp> #include <nostalgia/gfx/consts.hpp>
#include <nostalgia/core/ptidxconv.hpp> #include <nostalgia/gfx/ptidxconv.hpp>
#include "tilesheeteditormodel.hpp" #include "tilesheeteditormodel.hpp"
#include "tilesheetpixels.hpp" #include "tilesheetpixels.hpp"
namespace nostalgia::core { namespace nostalgia::gfx {
const glutils::ProgramSource TileSheetPixels::s_programSrc = { const glutils::ProgramSource TileSheetPixels::s_programSrc = {
.shaderParams = { .shaderParams = {
@ -29,7 +29,7 @@ const glutils::ProgramSource TileSheetPixels::s_programSrc = {
void main() { void main() {
gl_Position = vec4(vPosition + vScroll, 0.0, 1.0); gl_Position = vec4(vPosition + vScroll, 0.0, 1.0);
fColor = vColor; fColor = vColor;
})", core::gl::GlslVersion), })", gfx::gl::GlslVersion),
.fragShader = ox::sfmt(R"( .fragShader = ox::sfmt(R"(
{} {}
in vec3 fColor; in vec3 fColor;
@ -37,7 +37,7 @@ const glutils::ProgramSource TileSheetPixels::s_programSrc = {
void main() { void main() {
//outColor = vec4(0.0, 0.7, 1.0, 1.0); //outColor = vec4(0.0, 0.7, 1.0, 1.0);
outColor = vec4(fColor, 1.0); outColor = vec4(fColor, 1.0);
})", core::gl::GlslVersion), })", gfx::gl::GlslVersion),
}; };
TileSheetPixels::TileSheetPixels(TileSheetEditorModel &model) noexcept: m_model(model) { TileSheetPixels::TileSheetPixels(TileSheetEditorModel &model) noexcept: m_model(model) {
@ -131,7 +131,7 @@ void TileSheetPixels::setBufferObjects(ox::Vec2 const&paneSize) noexcept {
m_bufferSet.elements.resize(pixels * VertexEboLength); m_bufferSet.elements.resize(pixels * VertexEboLength);
// set pixels // set pixels
walkPixels(subSheet, m_model.img().bpp, [&](std::size_t i, uint8_t p) { walkPixels(subSheet, m_model.img().bpp, [&](std::size_t i, uint8_t p) {
auto color = core::color(pal, m_model.palettePage(), p); auto color = gfx::color(pal, m_model.palettePage(), p);
auto const pt = idxToPt(static_cast<int>(i), subSheet.columns); auto const pt = idxToPt(static_cast<int>(i), subSheet.columns);
auto const fx = static_cast<float>(pt.x); auto const fx = static_cast<float>(pt.x);
auto const fy = static_cast<float>(pt.y); auto const fy = static_cast<float>(pt.y);

View File

@ -9,10 +9,10 @@
#include <glutils/glutils.hpp> #include <glutils/glutils.hpp>
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/color.hpp> #include <nostalgia/gfx/color.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
class TileSheetPixels { class TileSheetPixels {

View File

@ -5,10 +5,10 @@
#include <ox/std/size.hpp> #include <ox/std/size.hpp>
#include <ox/std/vector.hpp> #include <ox/std/vector.hpp>
#include <nostalgia/core/ptidxconv.hpp> #include <nostalgia/gfx/ptidxconv.hpp>
#include <nostalgia/core/tilesheet.hpp> #include <nostalgia/gfx/tilesheet.hpp>
namespace nostalgia::core { namespace nostalgia::gfx {
std::size_t idx(TileSheet::SubSheet const&ss, ox::Point const&pt) noexcept { std::size_t idx(TileSheet::SubSheet const&ss, ox::Point const&pt) noexcept {
return ptToIdx(pt, ss.columns); return ptToIdx(pt, ss.columns);
@ -241,11 +241,11 @@ TileSheet::SubSheet &getSubSheet(
} }
TileSheet::SubSheet const&getSubSheet(TileSheet const&ts, TileSheet::SubSheetIdx const&idx) noexcept { TileSheet::SubSheet const&getSubSheet(TileSheet const&ts, TileSheet::SubSheetIdx const&idx) noexcept {
return core::getSubSheet(idx, 0, ts.subsheet); return gfx::getSubSheet(idx, 0, ts.subsheet);
} }
TileSheet::SubSheet &getSubSheet(TileSheet &ts, TileSheet::SubSheetIdx const&idx) noexcept { TileSheet::SubSheet &getSubSheet(TileSheet &ts, TileSheet::SubSheetIdx const&idx) noexcept {
return core::getSubSheet(idx, 0, ts.subsheet); return gfx::getSubSheet(idx, 0, ts.subsheet);
} }
ox::Error addSubSheet(TileSheet &ts, TileSheet::SubSheetIdx const&idx) noexcept { ox::Error addSubSheet(TileSheet &ts, TileSheet::SubSheetIdx const&idx) noexcept {
@ -382,15 +382,15 @@ static ox::Result<uint32_t> getTileOffset(
} }
ox::Result<uint32_t> getTileOffset(TileSheet const&ts, ox::StringViewCR pNamePath) noexcept { ox::Result<uint32_t> getTileOffset(TileSheet const&ts, ox::StringViewCR pNamePath) noexcept {
return core::getTileOffset(ts.subsheet, ox::split<8>(pNamePath, '.'), ts.bpp); return gfx::getTileOffset(ts.subsheet, ox::split<8>(pNamePath, '.'), ts.bpp);
} }
ox::Result<ox::StringView> getNameFor(TileSheet &ts, SubSheetId pId) noexcept { ox::Result<ox::StringView> getNameFor(TileSheet &ts, SubSheetId pId) noexcept {
return core::getNameFor(ts.subsheet, pId); return gfx::getNameFor(ts.subsheet, pId);
} }
ox::Result<ox::StringView> getNameFor(TileSheet const&ts, SubSheetId pId) noexcept { ox::Result<ox::StringView> getNameFor(TileSheet const&ts, SubSheetId pId) noexcept {
return core::getNameFor(ts.subsheet, pId); return gfx::getNameFor(ts.subsheet, pId);
} }
static void readPixelsTo(TileSheet::SubSheet &ss, ox::Vector<uint8_t> &pPixels) noexcept { static void readPixelsTo(TileSheet::SubSheet &ss, ox::Vector<uint8_t> &pPixels) noexcept {

View File

@ -7,7 +7,7 @@
#include <map> #include <map>
#include <ox/std/error.hpp> #include <ox/std/error.hpp>
#include <ox/mc/mc.hpp> #include <ox/mc/mc.hpp>
#include <nostalgia/core/core.hpp> #include <nostalgia/gfx/core.hpp>
using namespace nostalgia; using namespace nostalgia;
@ -15,9 +15,9 @@ static std::map<ox::StringView, ox::Error(*)()> tests = {
{ {
"readWriteTileSheet", "readWriteTileSheet",
[]() -> ox::Error { []() -> ox::Error {
core::TileSheet in; gfx::TileSheet in;
OX_REQUIRE(buff, ox::writeMC(in)); OX_REQUIRE(buff, ox::writeMC(in));
OX_REQUIRE(out, ox::readMC<core::TileSheet>(buff)); OX_REQUIRE(out, ox::readMC<gfx::TileSheet>(buff));
oxAssert(in.subsheet.name == out.subsheet.name, "subsheet.name serialization broken"); oxAssert(in.subsheet.name == out.subsheet.name, "subsheet.name serialization broken");
return {}; return {};
} }

View File

@ -2,7 +2,7 @@
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/ */
#include <nostalgia/core/keelmodule.hpp> #include <nostalgia/gfx/keelmodule.hpp>
#include <nostalgia/scene/keelmodule.hpp> #include <nostalgia/scene/keelmodule.hpp>
namespace nostalgia { namespace nostalgia {
@ -13,7 +13,7 @@ void registerKeelModules() noexcept {
return; return;
} }
modulesRegistered = true; modulesRegistered = true;
keel::registerModule(core::keelModule()); keel::registerModule(gfx::keelModule());
keel::registerModule(scene::keelModule()); keel::registerModule(scene::keelModule());
} }

View File

@ -4,7 +4,7 @@
#pragma once #pragma once
#include <nostalgia/core/context.hpp> #include <nostalgia/gfx/context.hpp>
#include "scenestatic.hpp" #include "scenestatic.hpp"
@ -17,10 +17,10 @@ class Scene {
public: public:
explicit Scene(SceneStatic const&sceneStatic) noexcept; explicit Scene(SceneStatic const&sceneStatic) noexcept;
ox::Error setupDisplay(core::Context &ctx) const noexcept; ox::Error setupDisplay(gfx::Context &ctx) const noexcept;
private: private:
void setupLayer(core::Context&, ox::Vector<uint16_t> const&layer, unsigned layerNo) const noexcept; void setupLayer(gfx::Context&, ox::Vector<uint16_t> const&layer, unsigned layerNo) const noexcept;
}; };

View File

@ -10,7 +10,7 @@
#include <ox/std/types.hpp> #include <ox/std/types.hpp>
#include <ox/std/vector.hpp> #include <ox/std/vector.hpp>
#include <nostalgia/core/tilesheet.hpp> #include <nostalgia/gfx/tilesheet.hpp>
namespace nostalgia::scene { namespace nostalgia::scene {
@ -21,7 +21,7 @@ struct SpriteDoc {
constexpr static auto Preloadable = true; constexpr static auto Preloadable = true;
ox::String tilesheetPath; ox::String tilesheetPath;
ox::Vector<core::SubSheetId> subsheetId; ox::Vector<gfx::SubSheetId> subsheetId;
}; };
@ -31,13 +31,13 @@ struct TileDoc {
constexpr static auto TypeVersion = 1; constexpr static auto TypeVersion = 1;
constexpr static auto Preloadable = true; constexpr static auto Preloadable = true;
core::SubSheetId subsheetId = -1; gfx::SubSheetId subsheetId = -1;
ox::String subsheetPath; ox::String subsheetPath;
uint8_t type = 0; uint8_t type = 0;
ox::Array<uint8_t, 4> layerAttachments; ox::Array<uint8_t, 4> layerAttachments;
[[nodiscard]] [[nodiscard]]
constexpr ox::Result<core::SubSheetId> getSubsheetId(core::TileSheet const&ts) const noexcept { constexpr ox::Result<gfx::SubSheetId> getSubsheetId(gfx::TileSheet const&ts) const noexcept {
// prefer the already present ID // prefer the already present ID
if (subsheetId > -1) { if (subsheetId > -1) {
return subsheetId; return subsheetId;
@ -47,10 +47,10 @@ struct TileDoc {
[[nodiscard]] [[nodiscard]]
constexpr ox::Result<ox::StringView> getSubsheetPath( constexpr ox::Result<ox::StringView> getSubsheetPath(
core::TileSheet const&ts) const noexcept { gfx::TileSheet const&ts) const noexcept {
// prefer the already present path // prefer the already present path
if (!subsheetPath.len()) { if (!subsheetPath.len()) {
return core::getNameFor(ts, subsheetId); return gfx::getNameFor(ts, subsheetId);
} }
return ox::StringView(subsheetPath); return ox::StringView(subsheetPath);
} }

View File

@ -2,7 +2,7 @@
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/ */
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include <keel/media.hpp> #include <keel/media.hpp>
#include "typeconv.hpp" #include "typeconv.hpp"
@ -37,7 +37,7 @@ ox::Error SceneDocToSceneStaticConverter::convert(
keel::Context &ctx, keel::Context &ctx,
SceneDoc &src, SceneDoc &src,
SceneStatic &dst) const noexcept { SceneStatic &dst) const noexcept {
OX_REQUIRE(ts, keel::readObj<core::TileSheet>(ctx, src.tilesheet)); OX_REQUIRE(ts, keel::readObj<gfx::TileSheet>(ctx, src.tilesheet));
const auto layerCnt = src.tiles.size(); const auto layerCnt = src.tiles.size();
dst.setLayerCnt(layerCnt); dst.setLayerCnt(layerCnt);
dst.tilesheet = ox::FileAddress(src.tilesheet); dst.tilesheet = ox::FileAddress(src.tilesheet);

View File

@ -2,7 +2,7 @@
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/ */
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include <nostalgia/scene/scene.hpp> #include <nostalgia/scene/scene.hpp>
@ -12,15 +12,15 @@ Scene::Scene(SceneStatic const&sceneStatic) noexcept:
m_sceneStatic(sceneStatic) { m_sceneStatic(sceneStatic) {
} }
ox::Error Scene::setupDisplay(core::Context &ctx) const noexcept { ox::Error Scene::setupDisplay(gfx::Context &ctx) const noexcept {
if (m_sceneStatic.palettes.empty()) { if (m_sceneStatic.palettes.empty()) {
return ox::Error(1, "Scene has no palettes"); return ox::Error(1, "Scene has no palettes");
} }
auto const&palette = m_sceneStatic.palettes[0]; auto const&palette = m_sceneStatic.palettes[0];
OX_RETURN_ERROR(core::loadBgTileSheet(ctx, 0, m_sceneStatic.tilesheet)); OX_RETURN_ERROR(gfx::loadBgTileSheet(ctx, 0, m_sceneStatic.tilesheet));
OX_RETURN_ERROR(core::loadBgPalette(ctx, 0, palette)); OX_RETURN_ERROR(gfx::loadBgPalette(ctx, 0, palette));
// disable all backgrounds // disable all backgrounds
core::setBgStatus(ctx, 0); gfx::setBgStatus(ctx, 0);
for (auto layerNo = 0u; auto const&layer : m_sceneStatic.tileMapIdx) { for (auto layerNo = 0u; auto const&layer : m_sceneStatic.tileMapIdx) {
setupLayer(ctx, layer, layerNo); setupLayer(ctx, layer, layerNo);
++layerNo; ++layerNo;
@ -29,20 +29,20 @@ ox::Error Scene::setupDisplay(core::Context &ctx) const noexcept {
} }
void Scene::setupLayer( void Scene::setupLayer(
core::Context &ctx, gfx::Context &ctx,
ox::Vector<uint16_t> const&layer, ox::Vector<uint16_t> const&layer,
unsigned layerNo) const noexcept { unsigned layerNo) const noexcept {
core::setBgStatus(ctx, layerNo, true); gfx::setBgStatus(ctx, layerNo, true);
core::setBgCbb(ctx, layerNo, 0); gfx::setBgCbb(ctx, layerNo, 0);
auto x = 0; auto x = 0;
auto y = 0; auto y = 0;
const auto width = m_sceneStatic.rows[layerNo]; const auto width = m_sceneStatic.rows[layerNo];
for (auto const&tile : layer) { for (auto const&tile : layer) {
const auto tile8 = static_cast<uint8_t>(tile); const auto tile8 = static_cast<uint8_t>(tile);
core::setBgTile(ctx, layerNo, x, y, tile8); gfx::setBgTile(ctx, layerNo, x, y, tile8);
core::setBgTile(ctx, layerNo, x + 1, y, tile8 + 1); gfx::setBgTile(ctx, layerNo, x + 1, y, tile8 + 1);
core::setBgTile(ctx, layerNo, x, y + 1, tile8 + 2); gfx::setBgTile(ctx, layerNo, x, y + 1, tile8 + 2);
core::setBgTile(ctx, layerNo, x + 1, y + 1, tile8 + 3); gfx::setBgTile(ctx, layerNo, x + 1, y + 1, tile8 + 3);
x += 2; x += 2;
if (x >= width * 2) { if (x >= width * 2) {
x = 0; x = 0;

View File

@ -2,31 +2,31 @@
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/ */
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include "sceneeditorview.hpp" #include "sceneeditorview.hpp"
namespace nostalgia::scene { namespace nostalgia::scene {
SceneEditorView::SceneEditorView(turbine::Context &tctx, SceneStatic const&sceneStatic): SceneEditorView::SceneEditorView(turbine::Context &tctx, SceneStatic const&sceneStatic):
m_cctx(core::init(tctx, {.glInstallDrawer = false}).unwrapThrow()), m_cctx(gfx::init(tctx, {.glInstallDrawer = false}).unwrapThrow()),
m_sceneStatic(sceneStatic), m_sceneStatic(sceneStatic),
m_scene(m_sceneStatic) { m_scene(m_sceneStatic) {
} }
ox::Error SceneEditorView::setupScene() noexcept { ox::Error SceneEditorView::setupScene() noexcept {
glutils::resizeInitFrameBuffer(m_frameBuffer, core::gl::drawSize(m_scale)); glutils::resizeInitFrameBuffer(m_frameBuffer, gfx::gl::drawSize(m_scale));
return m_scene.setupDisplay(*m_cctx); return m_scene.setupDisplay(*m_cctx);
} }
void SceneEditorView::draw(ox::Size const&targetSz) noexcept { void SceneEditorView::draw(ox::Size const&targetSz) noexcept {
auto const scaleSz = targetSz / core::gl::drawSize(1); auto const scaleSz = targetSz / gfx::gl::drawSize(1);
if (m_scaleSz != scaleSz) [[unlikely]] { if (m_scaleSz != scaleSz) [[unlikely]] {
m_scale = ox::max(1, ox::max(scaleSz.width, scaleSz.height)); m_scale = ox::max(1, ox::max(scaleSz.width, scaleSz.height));
glutils::resizeInitFrameBuffer(m_frameBuffer, core::gl::drawSize(m_scale)); glutils::resizeInitFrameBuffer(m_frameBuffer, gfx::gl::drawSize(m_scale));
} }
glutils::FrameBufferBind const frameBufferBind(m_frameBuffer); glutils::FrameBufferBind const frameBufferBind(m_frameBuffer);
core::gl::draw(*m_cctx, m_scale); gfx::gl::draw(*m_cctx, m_scale);
} }
glutils::FrameBuffer const&SceneEditorView::framebuffer() const noexcept { glutils::FrameBuffer const&SceneEditorView::framebuffer() const noexcept {

View File

@ -6,8 +6,8 @@
#include <glutils/glutils.hpp> #include <glutils/glutils.hpp>
#include <nostalgia/core/context.hpp> #include <nostalgia/gfx/context.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include <nostalgia/scene/scene.hpp> #include <nostalgia/scene/scene.hpp>
namespace nostalgia::scene { namespace nostalgia::scene {
@ -15,12 +15,12 @@ namespace nostalgia::scene {
class SceneEditorView { class SceneEditorView {
private: private:
core::ContextUPtr m_cctx; gfx::ContextUPtr m_cctx;
SceneStatic const&m_sceneStatic; SceneStatic const&m_sceneStatic;
Scene m_scene; Scene m_scene;
glutils::FrameBuffer m_frameBuffer; glutils::FrameBuffer m_frameBuffer;
int m_scale = 1; int m_scale = 1;
ox::Size m_scaleSz = core::gl::drawSize(m_scale); ox::Size m_scaleSz = gfx::gl::drawSize(m_scale);
public: public:
SceneEditorView(turbine::Context &ctx, SceneStatic const&sceneStatic); SceneEditorView(turbine::Context &ctx, SceneStatic const&sceneStatic);

View File

@ -4,7 +4,7 @@
#include <studioapp/studioapp.hpp> #include <studioapp/studioapp.hpp>
#include <nostalgia/core/studiomodule.hpp> #include <nostalgia/gfx/studiomodule.hpp>
#include <nostalgia/scene/studiomodule.hpp> #include <nostalgia/scene/studiomodule.hpp>
namespace nostalgia { namespace nostalgia {
@ -15,7 +15,7 @@ void registerStudioModules() noexcept {
return; return;
} }
modulesRegistered = true; modulesRegistered = true;
studio::registerModule(core::studioModule()); studio::registerModule(gfx::studioModule());
studio::registerModule(scene::studioModule()); studio::registerModule(scene::studioModule());
} }

View File

@ -5,7 +5,7 @@
#include <keel/media.hpp> #include <keel/media.hpp>
#include <turbine/turbine.hpp> #include <turbine/turbine.hpp>
#include <nostalgia/core/core.hpp> #include <nostalgia/gfx/core.hpp>
#include <nostalgia/scene/scene.hpp> #include <nostalgia/scene/scene.hpp>
using namespace nostalgia; using namespace nostalgia;
@ -16,7 +16,7 @@ static bool s_paused = false;
[[maybe_unused]] [[maybe_unused]]
static int testUpdateHandler(turbine::Context &tctx) noexcept { static int testUpdateHandler(turbine::Context &tctx) noexcept {
auto &cctx = *turbine::applicationData<core::Context>(tctx); auto &cctx = *turbine::applicationData<gfx::Context>(tctx);
constexpr auto sleepTime = 16; constexpr auto sleepTime = 16;
if (s_paused) { if (s_paused) {
return sleepTime; return sleepTime;
@ -41,7 +41,7 @@ static int testUpdateHandler(turbine::Context &tctx) noexcept {
constexpr ox::StringView sprites = "nostalgia"; constexpr ox::StringView sprites = "nostalgia";
for (unsigned i = 0; i < sprites.len(); ++i) { for (unsigned i = 0; i < sprites.len(); ++i) {
auto const c = static_cast<unsigned>(sprites[i] - ('a' - 1)); auto const c = static_cast<unsigned>(sprites[i] - ('a' - 1));
core::setSprite(cctx, i, { gfx::setSprite(cctx, i, {
.enabled = true, .enabled = true,
.x = spriteX + 8 * (static_cast<int>(i) + 1), .x = spriteX + 8 * (static_cast<int>(i) + 1),
.y = spriteY, .y = spriteY,
@ -67,13 +67,13 @@ static void testKeyEventHandler(turbine::Context &tctx, turbine::Key key, bool d
static ox::Error runTest(turbine::Context &tctx) { static ox::Error runTest(turbine::Context &tctx) {
constexpr ox::StringView TileSheetAddr{"/TileSheets/Charset.ng"}; constexpr ox::StringView TileSheetAddr{"/TileSheets/Charset.ng"};
constexpr ox::StringView PaletteAddr{"/Palettes/Chester.npal"}; constexpr ox::StringView PaletteAddr{"/Palettes/Chester.npal"};
OX_REQUIRE_M(cctx, core::init(tctx)); OX_REQUIRE_M(cctx, gfx::init(tctx));
turbine::setApplicationData(tctx, cctx.get()); turbine::setApplicationData(tctx, cctx.get());
OX_REQUIRE(tsStat, turbine::rom(tctx)->stat(PaletteAddr)); OX_REQUIRE(tsStat, turbine::rom(tctx)->stat(PaletteAddr));
OX_RETURN_ERROR(core::loadSpriteTileSheet(*cctx, TileSheetAddr)); OX_RETURN_ERROR(gfx::loadSpriteTileSheet(*cctx, TileSheetAddr));
OX_RETURN_ERROR(core::loadSpritePalette(*cctx, PaletteAddr)); OX_RETURN_ERROR(gfx::loadSpritePalette(*cctx, PaletteAddr));
OX_RETURN_ERROR(core::initConsole(*cctx)); OX_RETURN_ERROR(gfx::initConsole(*cctx));
core::puts(*cctx, 10, 9, "DOPENESS!!!"); gfx::puts(*cctx, 10, 9, "DOPENESS!!!");
turbine::setUpdateHandler(tctx, testUpdateHandler); turbine::setUpdateHandler(tctx, testUpdateHandler);
turbine::setKeyEventHandler(tctx, testKeyEventHandler); turbine::setKeyEventHandler(tctx, testKeyEventHandler);
return turbine::run(tctx); return turbine::run(tctx);
@ -85,10 +85,10 @@ static ox::Error runTileSheetSetTest(turbine::Context &tctx) {
// this should make the screen display 'ABCDB', with the A being upside down // this should make the screen display 'ABCDB', with the A being upside down
// and the first B being backwards // and the first B being backwards
constexpr ox::StringView PaletteAddr{"/Palettes/Charset.npal"}; constexpr ox::StringView PaletteAddr{"/Palettes/Charset.npal"};
OX_REQUIRE_M(cctx, core::init(tctx)); OX_REQUIRE_M(cctx, gfx::init(tctx));
turbine::setApplicationData(tctx, cctx.get()); turbine::setApplicationData(tctx, cctx.get());
OX_REQUIRE(tsStat, turbine::rom(tctx)->stat(PaletteAddr)); OX_REQUIRE(tsStat, turbine::rom(tctx)->stat(PaletteAddr));
core::TileSheetSet const set{ gfx::TileSheetSet const set{
.bpp = 4, .bpp = 4,
.entries = { .entries = {
{ .tilesheet = ox::StringLiteral{"/TileSheets/Chester.ng"}, .sections{{.begin = 0, .tiles = 1}} }, { .tilesheet = ox::StringLiteral{"/TileSheets/Chester.ng"}, .sections{{.begin = 0, .tiles = 1}} },
@ -98,23 +98,23 @@ static ox::Error runTileSheetSetTest(turbine::Context &tctx) {
}, },
}; };
constexpr auto bgPalBank = 1; constexpr auto bgPalBank = 1;
OX_RETURN_ERROR(core::loadBgTileSheet(*cctx, 0, set)); OX_RETURN_ERROR(gfx::loadBgTileSheet(*cctx, 0, set));
OX_RETURN_ERROR(core::loadSpriteTileSheet(*cctx, set)); OX_RETURN_ERROR(gfx::loadSpriteTileSheet(*cctx, set));
OX_RETURN_ERROR(core::loadBgPalette(*cctx, bgPalBank, PaletteAddr)); OX_RETURN_ERROR(gfx::loadBgPalette(*cctx, bgPalBank, PaletteAddr));
OX_RETURN_ERROR(core::loadBgPalette(*cctx, 0, PaletteAddr)); OX_RETURN_ERROR(gfx::loadBgPalette(*cctx, 0, PaletteAddr));
OX_RETURN_ERROR(core::loadSpritePalette(*cctx, PaletteAddr)); OX_RETURN_ERROR(gfx::loadSpritePalette(*cctx, PaletteAddr));
core::setBgStatus(*cctx, 0, true); gfx::setBgStatus(*cctx, 0, true);
core::setBgTile(*cctx, 0, 10, 9, { .tileIdx = 1, .palBank = bgPalBank, .flipX = 0, .flipY = 1 }); gfx::setBgTile(*cctx, 0, 10, 9, { .tileIdx = 1, .palBank = bgPalBank, .flipX = 0, .flipY = 1 });
core::setBgTile(*cctx, 0, 11, 9, { .tileIdx = 2, .palBank = bgPalBank, .flipX = 1, .flipY = 0 }); gfx::setBgTile(*cctx, 0, 11, 9, { .tileIdx = 2, .palBank = bgPalBank, .flipX = 1, .flipY = 0 });
core::setBgTile(*cctx, 0, 13, 9, { .tileIdx = 4, .palBank = bgPalBank, .flipX = 0, .flipY = 0 }); gfx::setBgTile(*cctx, 0, 13, 9, { .tileIdx = 4, .palBank = bgPalBank, .flipX = 0, .flipY = 0 });
core::setSprite(*cctx, 16, { gfx::setSprite(*cctx, 16, {
.enabled = true, .enabled = true,
.x = 12 * 8, .x = 12 * 8,
.y = 9 * 8, .y = 9 * 8,
.tileIdx = 3, .tileIdx = 3,
.bpp = static_cast<unsigned>(set.bpp), .bpp = static_cast<unsigned>(set.bpp),
}); });
core::setSprite(*cctx, 17, { gfx::setSprite(*cctx, 17, {
.enabled = true, .enabled = true,
.x = 14 * 8, .x = 14 * 8,
.y = 9 * 8, .y = 9 * 8,
@ -148,7 +148,7 @@ static void sceneKeyEventHandler(turbine::Context &tctx, turbine::Key key, bool
[[maybe_unused]] [[maybe_unused]]
static ox::Error runScene(turbine::Context &tctx) { static ox::Error runScene(turbine::Context &tctx) {
constexpr ox::StringView SceneAddr{"/Scenes/Chester.nscn"}; constexpr ox::StringView SceneAddr{"/Scenes/Chester.nscn"};
OX_REQUIRE_M(cctx, core::init(tctx)); OX_REQUIRE_M(cctx, gfx::init(tctx));
OX_REQUIRE(scn, keel::readObj<scene::SceneStatic>(keelCtx(tctx), SceneAddr)); OX_REQUIRE(scn, keel::readObj<scene::SceneStatic>(keelCtx(tctx), SceneAddr));
turbine::setUpdateHandler(tctx, sceneUpdateHandler); turbine::setUpdateHandler(tctx, sceneUpdateHandler);
turbine::setKeyEventHandler(tctx, sceneKeyEventHandler); turbine::setKeyEventHandler(tctx, sceneKeyEventHandler);