Compare commits
No commits in common. "672b92b363a2047c4c8ce93fb3d88001a76da35f" and "d141154a4589c570d15280d194d6c9feadb7484b" have entirely different histories.
672b92b363
...
d141154a45
@ -1,6 +1,6 @@
|
||||
# module dir list
|
||||
|
||||
add_subdirectory(gfx)
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(scene)
|
||||
|
||||
# module libraries
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <ox/std/math.hpp>
|
||||
#include <ox/std/types.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
using Color16 = uint16_t;
|
||||
|
||||
@ -154,7 +154,7 @@ static_assert(color16(16, 32, 8) == 9200);
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Color16 applySelectionColor(Color16 const color) noexcept {
|
||||
namespace core = nostalgia::gfx;
|
||||
namespace core = nostalgia::core;
|
||||
auto const r = core::red16(color) / 2;
|
||||
auto const g = (core::green16(color) + 20) / 2;
|
||||
auto const b = (core::blue16(color) + 31) / 2;
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <ox/std/stringliteral.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
constexpr auto TileWidth = 8;
|
||||
constexpr auto TileHeight = 8;
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include "initparams.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class Context;
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "palette.hpp"
|
||||
#include "tilesheet.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
struct 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::gfx::gl {
|
||||
namespace nostalgia::core::gl {
|
||||
|
||||
constexpr ox::CStringView GlslVersion = "#version 330";
|
||||
|
||||
[[nodiscard]]
|
||||
ox::Size drawSize(int scale = 5) noexcept;
|
||||
|
||||
void draw(gfx::Context &ctx, ox::Size const&renderSz) noexcept;
|
||||
void draw(core::Context &ctx, ox::Size const&renderSz) noexcept;
|
||||
|
||||
void draw(gfx::Context&, int scale = 5) noexcept;
|
||||
void draw(core::Context&, int scale = 5) noexcept;
|
||||
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <ox/std/types.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
struct InitParams {
|
||||
bool glInstallDrawer = true;
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <keel/module.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
const keel::Module *keelModule() noexcept;
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "color.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
struct PaletteColorV1 {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.PaletteColor";
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include "consts.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr std::size_t ptToIdx(int x, int y, int c, int scale = 1) noexcept {
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
const studio::Module *studioModule() noexcept;
|
||||
|
@ -12,11 +12,11 @@
|
||||
#include <ox/std/types.hpp>
|
||||
#include <ox/model/def.hpp>
|
||||
|
||||
#include <nostalgia/gfx/ptidxconv.hpp>
|
||||
#include <nostalgia/core/ptidxconv.hpp>
|
||||
|
||||
#include "palette.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
struct SubSheetTemplate {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.SubSheetTemplate";
|
@ -4,11 +4,11 @@
|
||||
|
||||
#include <turbine/turbine.hpp>
|
||||
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
|
||||
#include "context.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
void safeDelete(Context *ctx) noexcept {
|
||||
delete ctx;
|
@ -4,9 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nostalgia/gfx/context.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
struct BgCbbData {
|
||||
unsigned bpp = 4;
|
@ -11,15 +11,15 @@
|
||||
|
||||
#include <keel/keel.hpp>
|
||||
|
||||
#include <nostalgia/gfx/context.hpp>
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
#include <nostalgia/gfx/tilesheet.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/core/tilesheet.hpp>
|
||||
|
||||
#include "context.hpp"
|
||||
|
||||
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
static constexpr auto SpriteCount = 128;
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nostalgia/gfx/context.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
ox::Error initGfx(Context &ctx, InitParams const&) noexcept;
|
||||
}
|
@ -12,7 +12,7 @@
|
||||
#include <teagba/addresses.hpp>
|
||||
#include <teagba/bios.hpp>
|
||||
|
||||
#include <nostalgia/gfx/core.hpp>
|
||||
#include <nostalgia/core/core.hpp>
|
||||
|
||||
#include "gfx.hpp"
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
namespace ox {
|
||||
|
||||
using namespace nostalgia::gfx;
|
||||
using namespace nostalgia::core;
|
||||
|
||||
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
|
@ -3,9 +3,9 @@
|
||||
*/
|
||||
|
||||
#include <keel/media.hpp>
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
constexpr auto GbaTileColumns = 32;
|
||||
constexpr auto GbaTileRows = 32;
|
@ -7,12 +7,12 @@
|
||||
#include <keel/asset.hpp>
|
||||
#include <keel/module.hpp>
|
||||
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
#include <nostalgia/gfx/tilesheet.hpp>
|
||||
#include <nostalgia/core/palette.hpp>
|
||||
#include <nostalgia/core/tilesheet.hpp>
|
||||
|
||||
#include "typeconv.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
static class: public keel::Module {
|
||||
private:
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "typeconv.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
ox::Error NostalgiaPaletteToPaletteV1Converter::convert(
|
||||
keel::Context&,
|
@ -8,11 +8,11 @@
|
||||
|
||||
#include <keel/typeconv.hpp>
|
||||
|
||||
#include <nostalgia/gfx/context.hpp>
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
#include <nostalgia/gfx/tilesheet.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
#include <nostalgia/core/palette.hpp>
|
||||
#include <nostalgia/core/tilesheet.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
// Type converters
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "context.hpp"
|
||||
#include "gfx.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
void safeDelete(Context *ctx) noexcept {
|
||||
delete ctx;
|
@ -8,12 +8,12 @@
|
||||
|
||||
#include <glutils/glutils.hpp>
|
||||
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
#include <nostalgia/gfx/context.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
|
||||
#include "gfx.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class Context {
|
||||
|
@ -10,15 +10,15 @@
|
||||
|
||||
#include <glutils/glutils.hpp>
|
||||
|
||||
#include <nostalgia/gfx/context.hpp>
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
#include <nostalgia/gfx/tilesheet.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/core/palette.hpp>
|
||||
#include <nostalgia/core/tilesheet.hpp>
|
||||
|
||||
#include "context.hpp"
|
||||
#include "gfx.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
namespace renderer {
|
||||
|
||||
@ -28,7 +28,7 @@ static constexpr auto PriorityScale = 0.01f;
|
||||
Drawer::Drawer(Context &ctx) noexcept: m_ctx(ctx) {}
|
||||
|
||||
void Drawer::draw(turbine::Context &tctx) noexcept {
|
||||
gfx::gl::draw(m_ctx, turbine::getScreenSize(tctx));
|
||||
core::gl::draw(m_ctx, turbine::getScreenSize(tctx));
|
||||
}
|
||||
|
||||
static constexpr ox::CStringView bgvshadTmpl = R"glsl(
|
||||
@ -768,7 +768,7 @@ ox::Size drawSize(int scale) noexcept {
|
||||
return {240 * scale, 160 * scale};
|
||||
}
|
||||
|
||||
void draw(gfx::Context &ctx, ox::Size const&renderSz) noexcept {
|
||||
void draw(core::Context &ctx, ox::Size const&renderSz) noexcept {
|
||||
glViewport(0, 0, renderSz.width, renderSz.height);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
@ -783,7 +783,7 @@ void draw(gfx::Context &ctx, ox::Size const&renderSz) noexcept {
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
void draw(gfx::Context &ctx, int scale) noexcept {
|
||||
void draw(core::Context &ctx, int scale) noexcept {
|
||||
draw(ctx, drawSize(scale));
|
||||
}
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
#include <glutils/glutils.hpp>
|
||||
|
||||
#include <nostalgia/gfx/context.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
|
||||
namespace nostalgia::gfx::renderer {
|
||||
namespace nostalgia::core::renderer {
|
||||
|
||||
constexpr uint64_t TileRows = 128;
|
||||
constexpr uint64_t TileColumns = 128;
|
||||
@ -59,7 +59,7 @@ class Drawer: public turbine::gl::Drawer {
|
||||
|
||||
}
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
ox::Error initGfx(Context &ctx, InitParams const&) noexcept;
|
||||
void shutdownGfx(Context &ctx) noexcept;
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
#include "commands.hpp"
|
||||
#include "addcolorcommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
AddColorCommand::AddColorCommand(Palette &pal, Color16 const color, size_t const idx) noexcept:
|
||||
m_pal(pal),
|
@ -6,9 +6,9 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
#include <nostalgia/core/palette.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class AddColorCommand: public studio::UndoCommand {
|
||||
private:
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "addpagecommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
AddPageCommand::AddPageCommand(Palette &pal) noexcept:
|
||||
m_pal(pal) {}
|
@ -6,9 +6,9 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
#include <nostalgia/core/palette.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class AddPageCommand: public studio::UndoCommand {
|
||||
private:
|
@ -5,7 +5,7 @@
|
||||
#include "commands.hpp"
|
||||
#include "applycolorallpagescommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
ApplyColorAllPagesCommand::ApplyColorAllPagesCommand(Palette &pal, size_t const page, size_t const idx):
|
||||
m_pal(pal),
|
@ -6,9 +6,9 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
#include <nostalgia/core/palette.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class ApplyColorAllPagesCommand: public studio::UndoCommand {
|
||||
private:
|
@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
enum class PaletteEditorCommandId {
|
||||
ApplyColorAllPages,
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "duplicatepagecommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
DuplicatePageCommand::DuplicatePageCommand(Palette &pal, size_t srcIdx, size_t dstIdx) noexcept:
|
||||
m_pal(pal),
|
@ -6,9 +6,9 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
#include <nostalgia/core/palette.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class DuplicatePageCommand: public studio::UndoCommand {
|
||||
private:
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "movecolorcommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
MoveColorCommand::MoveColorCommand(
|
||||
Palette &pal, size_t page, size_t srcIdx, size_t dstIdx) noexcept:
|
@ -6,9 +6,9 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
#include <nostalgia/core/palette.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class MoveColorCommand: public studio::UndoCommand {
|
||||
private:
|
@ -5,7 +5,7 @@
|
||||
#include "commands.hpp"
|
||||
#include "removecolorcommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
RemoveColorCommand::RemoveColorCommand(Palette &pal, size_t const idx) noexcept:
|
||||
m_pal(pal),
|
@ -6,9 +6,9 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
#include <nostalgia/core/palette.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class RemoveColorCommand: public studio::UndoCommand {
|
||||
private:
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "removepagecommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
RemovePageCommand::RemovePageCommand(Palette &pal, size_t idx) noexcept:
|
||||
m_pal(pal),
|
@ -6,9 +6,9 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
#include <nostalgia/core/palette.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class RemovePageCommand: public studio::UndoCommand {
|
||||
private:
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "renamepagecommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
RenamePageCommand::RenamePageCommand(Palette &pal, size_t const page, ox::StringParam name) noexcept:
|
||||
m_pal(pal),
|
@ -6,11 +6,11 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
#include <nostalgia/core/palette.hpp>
|
||||
|
||||
#include "commands.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class RenamePageCommand: public studio::UndoCommand {
|
||||
private:
|
@ -5,7 +5,7 @@
|
||||
#include "commands.hpp"
|
||||
#include "updatecolorcommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
UpdateColorCommand::UpdateColorCommand(
|
||||
Palette &pal,
|
@ -6,9 +6,9 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
#include <nostalgia/core/palette.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class UpdateColorCommand: public studio::UndoCommand {
|
||||
private:
|
@ -5,7 +5,7 @@
|
||||
#include "commands.hpp"
|
||||
#include "updatecolorinfocommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
UpdateColorInfoCommand::UpdateColorInfoCommand(
|
||||
Palette &pal,
|
@ -6,9 +6,9 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
#include <nostalgia/core/palette.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class UpdateColorInfoCommand: public studio::UndoCommand {
|
||||
private:
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "paletteeditor-imgui.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
namespace ig = studio::ig;
|
||||
|
@ -6,10 +6,10 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/core/palette.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class PaletteEditorImGui: public studio::Editor {
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "paletteeditor/paletteeditor-imgui.hpp"
|
||||
#include "tilesheeteditor/tilesheeteditor-imgui.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
static class: public studio::Module {
|
||||
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<Palette>>("Palette", "Palettes", FileExt_npal, Palette{
|
||||
.colorNames = {},
|
||||
.pages = {{"Page 1", ox::Vector<PaletteColor>{}}},
|
||||
.pages = {{"Page 1", ox::Vector<PaletteColorV1>{}}},
|
||||
}, ox::ClawFormat::Organic));
|
||||
return out;
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "addsubsheetcommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
AddSubSheetCommand::AddSubSheetCommand(
|
||||
TileSheet &img,
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "commands.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class AddSubSheetCommand: public TileSheetCommand {
|
||||
private:
|
@ -5,9 +5,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <studio/undostack.hpp>
|
||||
#include <nostalgia/gfx/tilesheet.hpp>
|
||||
#include <nostalgia/core/tilesheet.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
// Command IDs to use with QUndoCommand::id()
|
||||
enum class CommandId {
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "cutpastecommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
TileSheetClipboard::Pixel::Pixel(uint16_t pColorIdx, ox::Point pPt) noexcept {
|
||||
colorIdx = pColorIdx;
|
||||
@ -37,7 +37,7 @@ CutPasteCommand::CutPasteCommand(
|
||||
for (auto const&p : cb.pixels()) {
|
||||
auto const dstPt = p.pt + dstStart;
|
||||
if (dstPt.x <= dstEnd.x && dstPt.y <= dstEnd.y) {
|
||||
auto const idx = gfx::idx(ss, dstPt);
|
||||
auto const idx = core::idx(ss, dstPt);
|
||||
m_changes.emplace_back(static_cast<uint32_t>(idx), p.colorIdx, getPixel(ss, m_img.bpp, idx));
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include "commands.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
OX_MODEL_FWD_DECL(class TileSheetClipboard);
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
#include "deletetilescommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
gfx::DeleteTilesCommand::DeleteTilesCommand(
|
||||
core::DeleteTilesCommand::DeleteTilesCommand(
|
||||
TileSheet &img,
|
||||
TileSheet::SubSheetIdx idx,
|
||||
std::size_t tileIdx,
|
||||
@ -28,7 +28,7 @@ gfx::DeleteTilesCommand::DeleteTilesCommand(
|
||||
}
|
||||
}
|
||||
|
||||
ox::Error gfx::DeleteTilesCommand::redo() noexcept {
|
||||
ox::Error core::DeleteTilesCommand::redo() noexcept {
|
||||
auto &s = getSubSheet(m_img, m_idx);
|
||||
auto &p = s.pixels;
|
||||
auto srcPos = m_deletePos + m_deleteSz;
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "commands.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class DeleteTilesCommand: public TileSheetCommand {
|
||||
private:
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "drawcommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
DrawCommand::DrawCommand(
|
||||
TileSheet &img,
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "commands.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class DrawCommand: public TileSheetCommand {
|
||||
private:
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "inserttilescommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
InsertTilesCommand::InsertTilesCommand(
|
||||
TileSheet &img,
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "commands.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class InsertTilesCommand: public TileSheetCommand {
|
||||
private:
|
@ -4,9 +4,9 @@
|
||||
|
||||
#include "palettechangecommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
gfx::PaletteChangeCommand::PaletteChangeCommand(
|
||||
core::PaletteChangeCommand::PaletteChangeCommand(
|
||||
TileSheet::SubSheetIdx idx,
|
||||
TileSheet &img,
|
||||
ox::StringViewCR newPalette) noexcept:
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "commands.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class PaletteChangeCommand: public TileSheetCommand {
|
||||
private:
|
@ -4,9 +4,9 @@
|
||||
|
||||
#include "rmsubsheetcommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
gfx::RmSubSheetCommand::RmSubSheetCommand(TileSheet &img, TileSheet::SubSheetIdx idx) noexcept:
|
||||
core::RmSubSheetCommand::RmSubSheetCommand(TileSheet &img, TileSheet::SubSheetIdx idx) noexcept:
|
||||
m_img(img),
|
||||
m_idx(std::move(idx)),
|
||||
m_parentIdx(m_idx) {
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "commands.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class RmSubSheetCommand: public TileSheetCommand {
|
||||
private:
|
@ -4,9 +4,9 @@
|
||||
|
||||
#include "updatesubsheetcommand.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
gfx::UpdateSubSheetCommand::UpdateSubSheetCommand(
|
||||
core::UpdateSubSheetCommand::UpdateSubSheetCommand(
|
||||
TileSheet &img,
|
||||
TileSheet::SubSheetIdx idx,
|
||||
ox::StringParam name,
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "commands.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class UpdateSubSheetCommand: public TileSheetCommand {
|
||||
private:
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "tilesheeteditor-imgui.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
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 pal = m_model.pal();
|
||||
if (!popupOpen) {
|
||||
auto const colorCnt = gfx::colorCnt(pal, m_model.palettePage());
|
||||
auto const colorCnt = core::colorCnt(pal, m_model.palettePage());
|
||||
if (key == turbine::Key::Alpha_D) {
|
||||
m_tool = TileSheetTool::Draw;
|
||||
setCopyEnabled(false);
|
@ -14,7 +14,7 @@
|
||||
#include "tilesheetpixels.hpp"
|
||||
#include "tilesheeteditorview.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class TileSheetEditorImGui: public studio::Editor {
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <turbine/clipboard.hpp>
|
||||
#include <keel/media.hpp>
|
||||
|
||||
#include <nostalgia/gfx/ptidxconv.hpp>
|
||||
#include <nostalgia/core/ptidxconv.hpp>
|
||||
|
||||
#include "commands/commands.hpp"
|
||||
#include "commands/addsubsheetcommand.hpp"
|
||||
@ -24,7 +24,7 @@
|
||||
#include "commands/updatesubsheetcommand.hpp"
|
||||
#include "tilesheeteditormodel.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
// delete pixels of all non-leaf nodes
|
||||
static void normalizeSubsheets(TileSheet::SubSheet &ss) noexcept {
|
||||
@ -66,7 +66,7 @@ void TileSheetEditorModel::cut() {
|
||||
auto const&s = activeSubSheet();
|
||||
iterateSelectionRows(*m_selection, [&](int const x, int const y) {
|
||||
auto pt = ox::Point{x, y};
|
||||
auto const idx = gfx::idx(s, pt);
|
||||
auto const idx = core::idx(s, pt);
|
||||
auto const c = getPixel(s, m_img.bpp, idx);
|
||||
pt -= m_selection->a;
|
||||
cb->addPixel(pt, c);
|
||||
@ -87,7 +87,7 @@ void TileSheetEditorModel::copy() {
|
||||
iterateSelectionRows(*m_selection, [&](int const x, int const y) {
|
||||
auto pt = ox::Point{x, y};
|
||||
const auto&s = activeSubSheet();
|
||||
const auto idx = gfx::idx(s, pt);
|
||||
const auto idx = core::idx(s, pt);
|
||||
const auto c = getPixel(s, m_img.bpp, idx);
|
||||
pt -= m_selection->a;
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
const auto idx = gfx::idx(activeSubSheet, pt);
|
||||
const auto idx = core::idx(activeSubSheet, pt);
|
||||
if (m_ongoingDrawCommand) {
|
||||
m_updated = m_updated || m_ongoingDrawCommand->append(idx);
|
||||
} 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);
|
||||
getFillPixels(activeSubSheet, updateMap, pt, oldColor);
|
||||
ox::Vector<std::size_t> idxList;
|
||||
auto i = gfx::idx(activeSubSheet, pt) / PixelsPerTile * PixelsPerTile;
|
||||
auto i = core::idx(activeSubSheet, pt) / PixelsPerTile * PixelsPerTile;
|
||||
for (auto const u : updateMap) {
|
||||
if (u) {
|
||||
idxList.emplace_back(i);
|
@ -9,10 +9,10 @@
|
||||
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
#include <nostalgia/gfx/tilesheet.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/core/tilesheet.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class TileSheetEditorModel: public ox::SignalHandler {
|
||||
|
@ -5,11 +5,11 @@
|
||||
#include <ox/std/point.hpp>
|
||||
#include <keel/media.hpp>
|
||||
|
||||
#include <nostalgia/gfx/consts.hpp>
|
||||
#include <nostalgia/core/consts.hpp>
|
||||
|
||||
#include "tilesheeteditorview.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
TileSheetEditorView::TileSheetEditorView(studio::StudioContext &sctx, ox::StringView path, studio::UndoStack &undoStack):
|
||||
m_model(sctx, path, undoStack),
|
@ -10,13 +10,13 @@
|
||||
#include <glutils/glutils.hpp>
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
|
||||
#include "tilesheeteditormodel.hpp"
|
||||
#include "tilesheetpixelgrid.hpp"
|
||||
#include "tilesheetpixels.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
enum class TileSheetTool {
|
||||
None,
|
@ -4,11 +4,11 @@
|
||||
|
||||
#include <ox/claw/write.hpp>
|
||||
|
||||
#include <nostalgia/gfx/consts.hpp>
|
||||
#include <nostalgia/core/consts.hpp>
|
||||
|
||||
#include "tilesheetpixelgrid.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
void TileSheetGrid::setPixelSizeMod(float sm) noexcept {
|
||||
m_pixelSizeMod = sm;
|
@ -7,10 +7,10 @@
|
||||
#include <glutils/glutils.hpp>
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
#include <nostalgia/gfx/tilesheet.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/core/tilesheet.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class TileSheetGrid {
|
||||
|
@ -2,12 +2,12 @@
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nostalgia/gfx/consts.hpp>
|
||||
#include <nostalgia/gfx/ptidxconv.hpp>
|
||||
#include <nostalgia/core/consts.hpp>
|
||||
#include <nostalgia/core/ptidxconv.hpp>
|
||||
#include "tilesheeteditormodel.hpp"
|
||||
#include "tilesheetpixels.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
const glutils::ProgramSource TileSheetPixels::s_programSrc = {
|
||||
.shaderParams = {
|
||||
@ -29,7 +29,7 @@ const glutils::ProgramSource TileSheetPixels::s_programSrc = {
|
||||
void main() {
|
||||
gl_Position = vec4(vPosition + vScroll, 0.0, 1.0);
|
||||
fColor = vColor;
|
||||
})", gfx::gl::GlslVersion),
|
||||
})", core::gl::GlslVersion),
|
||||
.fragShader = ox::sfmt(R"(
|
||||
{}
|
||||
in vec3 fColor;
|
||||
@ -37,7 +37,7 @@ const glutils::ProgramSource TileSheetPixels::s_programSrc = {
|
||||
void main() {
|
||||
//outColor = vec4(0.0, 0.7, 1.0, 1.0);
|
||||
outColor = vec4(fColor, 1.0);
|
||||
})", gfx::gl::GlslVersion),
|
||||
})", core::gl::GlslVersion),
|
||||
};
|
||||
|
||||
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);
|
||||
// set pixels
|
||||
walkPixels(subSheet, m_model.img().bpp, [&](std::size_t i, uint8_t p) {
|
||||
auto color = gfx::color(pal, m_model.palettePage(), p);
|
||||
auto color = core::color(pal, m_model.palettePage(), p);
|
||||
auto const pt = idxToPt(static_cast<int>(i), subSheet.columns);
|
||||
auto const fx = static_cast<float>(pt.x);
|
||||
auto const fy = static_cast<float>(pt.y);
|
@ -9,10 +9,10 @@
|
||||
#include <glutils/glutils.hpp>
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/color.hpp>
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
#include <nostalgia/core/color.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
class TileSheetPixels {
|
||||
|
@ -5,10 +5,10 @@
|
||||
#include <ox/std/size.hpp>
|
||||
#include <ox/std/vector.hpp>
|
||||
|
||||
#include <nostalgia/gfx/ptidxconv.hpp>
|
||||
#include <nostalgia/gfx/tilesheet.hpp>
|
||||
#include <nostalgia/core/ptidxconv.hpp>
|
||||
#include <nostalgia/core/tilesheet.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
namespace nostalgia::core {
|
||||
|
||||
std::size_t idx(TileSheet::SubSheet const&ss, ox::Point const&pt) noexcept {
|
||||
return ptToIdx(pt, ss.columns);
|
||||
@ -241,11 +241,11 @@ TileSheet::SubSheet &getSubSheet(
|
||||
}
|
||||
|
||||
TileSheet::SubSheet const&getSubSheet(TileSheet const&ts, TileSheet::SubSheetIdx const&idx) noexcept {
|
||||
return gfx::getSubSheet(idx, 0, ts.subsheet);
|
||||
return core::getSubSheet(idx, 0, ts.subsheet);
|
||||
}
|
||||
|
||||
TileSheet::SubSheet &getSubSheet(TileSheet &ts, TileSheet::SubSheetIdx const&idx) noexcept {
|
||||
return gfx::getSubSheet(idx, 0, ts.subsheet);
|
||||
return core::getSubSheet(idx, 0, ts.subsheet);
|
||||
}
|
||||
|
||||
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 {
|
||||
return gfx::getTileOffset(ts.subsheet, ox::split<8>(pNamePath, '.'), ts.bpp);
|
||||
return core::getTileOffset(ts.subsheet, ox::split<8>(pNamePath, '.'), ts.bpp);
|
||||
}
|
||||
|
||||
ox::Result<ox::StringView> getNameFor(TileSheet &ts, SubSheetId pId) noexcept {
|
||||
return gfx::getNameFor(ts.subsheet, pId);
|
||||
return core::getNameFor(ts.subsheet, pId);
|
||||
}
|
||||
|
||||
ox::Result<ox::StringView> getNameFor(TileSheet const&ts, SubSheetId pId) noexcept {
|
||||
return gfx::getNameFor(ts.subsheet, pId);
|
||||
return core::getNameFor(ts.subsheet, pId);
|
||||
}
|
||||
|
||||
static void readPixelsTo(TileSheet::SubSheet &ss, ox::Vector<uint8_t> &pPixels) noexcept {
|
@ -7,7 +7,7 @@
|
||||
#include <map>
|
||||
#include <ox/std/error.hpp>
|
||||
#include <ox/mc/mc.hpp>
|
||||
#include <nostalgia/gfx/core.hpp>
|
||||
#include <nostalgia/core/core.hpp>
|
||||
|
||||
using namespace nostalgia;
|
||||
|
||||
@ -15,9 +15,9 @@ static std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
{
|
||||
"readWriteTileSheet",
|
||||
[]() -> ox::Error {
|
||||
gfx::TileSheet in;
|
||||
core::TileSheet in;
|
||||
OX_REQUIRE(buff, ox::writeMC(in));
|
||||
OX_REQUIRE(out, ox::readMC<gfx::TileSheet>(buff));
|
||||
OX_REQUIRE(out, ox::readMC<core::TileSheet>(buff));
|
||||
oxAssert(in.subsheet.name == out.subsheet.name, "subsheet.name serialization broken");
|
||||
return {};
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nostalgia/gfx/keelmodule.hpp>
|
||||
#include <nostalgia/core/keelmodule.hpp>
|
||||
#include <nostalgia/scene/keelmodule.hpp>
|
||||
|
||||
namespace nostalgia {
|
||||
@ -13,7 +13,7 @@ void registerKeelModules() noexcept {
|
||||
return;
|
||||
}
|
||||
modulesRegistered = true;
|
||||
keel::registerModule(gfx::keelModule());
|
||||
keel::registerModule(core::keelModule());
|
||||
keel::registerModule(scene::keelModule());
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nostalgia/gfx/context.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
|
||||
#include "scenestatic.hpp"
|
||||
|
||||
@ -17,10 +17,10 @@ class Scene {
|
||||
public:
|
||||
explicit Scene(SceneStatic const&sceneStatic) noexcept;
|
||||
|
||||
ox::Error setupDisplay(gfx::Context &ctx) const noexcept;
|
||||
ox::Error setupDisplay(core::Context &ctx) const noexcept;
|
||||
|
||||
private:
|
||||
void setupLayer(gfx::Context&, ox::Vector<uint16_t> const&layer, unsigned layerNo) const noexcept;
|
||||
void setupLayer(core::Context&, ox::Vector<uint16_t> const&layer, unsigned layerNo) const noexcept;
|
||||
|
||||
};
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <ox/std/types.hpp>
|
||||
#include <ox/std/vector.hpp>
|
||||
|
||||
#include <nostalgia/gfx/tilesheet.hpp>
|
||||
#include <nostalgia/core/tilesheet.hpp>
|
||||
|
||||
namespace nostalgia::scene {
|
||||
|
||||
@ -21,7 +21,7 @@ struct SpriteDoc {
|
||||
constexpr static auto Preloadable = true;
|
||||
|
||||
ox::String tilesheetPath;
|
||||
ox::Vector<gfx::SubSheetId> subsheetId;
|
||||
ox::Vector<core::SubSheetId> subsheetId;
|
||||
|
||||
};
|
||||
|
||||
@ -31,13 +31,13 @@ struct TileDoc {
|
||||
constexpr static auto TypeVersion = 1;
|
||||
constexpr static auto Preloadable = true;
|
||||
|
||||
gfx::SubSheetId subsheetId = -1;
|
||||
core::SubSheetId subsheetId = -1;
|
||||
ox::String subsheetPath;
|
||||
uint8_t type = 0;
|
||||
ox::Array<uint8_t, 4> layerAttachments;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr ox::Result<gfx::SubSheetId> getSubsheetId(gfx::TileSheet const&ts) const noexcept {
|
||||
constexpr ox::Result<core::SubSheetId> getSubsheetId(core::TileSheet const&ts) const noexcept {
|
||||
// prefer the already present ID
|
||||
if (subsheetId > -1) {
|
||||
return subsheetId;
|
||||
@ -47,10 +47,10 @@ struct TileDoc {
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr ox::Result<ox::StringView> getSubsheetPath(
|
||||
gfx::TileSheet const&ts) const noexcept {
|
||||
core::TileSheet const&ts) const noexcept {
|
||||
// prefer the already present path
|
||||
if (!subsheetPath.len()) {
|
||||
return gfx::getNameFor(ts, subsheetId);
|
||||
return core::getNameFor(ts, subsheetId);
|
||||
}
|
||||
return ox::StringView(subsheetPath);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <keel/media.hpp>
|
||||
|
||||
#include "typeconv.hpp"
|
||||
@ -37,7 +37,7 @@ ox::Error SceneDocToSceneStaticConverter::convert(
|
||||
keel::Context &ctx,
|
||||
SceneDoc &src,
|
||||
SceneStatic &dst) const noexcept {
|
||||
OX_REQUIRE(ts, keel::readObj<gfx::TileSheet>(ctx, src.tilesheet));
|
||||
OX_REQUIRE(ts, keel::readObj<core::TileSheet>(ctx, src.tilesheet));
|
||||
const auto layerCnt = src.tiles.size();
|
||||
dst.setLayerCnt(layerCnt);
|
||||
dst.tilesheet = ox::FileAddress(src.tilesheet);
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
|
||||
#include <nostalgia/scene/scene.hpp>
|
||||
|
||||
@ -12,15 +12,15 @@ Scene::Scene(SceneStatic const&sceneStatic) noexcept:
|
||||
m_sceneStatic(sceneStatic) {
|
||||
}
|
||||
|
||||
ox::Error Scene::setupDisplay(gfx::Context &ctx) const noexcept {
|
||||
ox::Error Scene::setupDisplay(core::Context &ctx) const noexcept {
|
||||
if (m_sceneStatic.palettes.empty()) {
|
||||
return ox::Error(1, "Scene has no palettes");
|
||||
}
|
||||
auto const&palette = m_sceneStatic.palettes[0];
|
||||
OX_RETURN_ERROR(gfx::loadBgTileSheet(ctx, 0, m_sceneStatic.tilesheet));
|
||||
OX_RETURN_ERROR(gfx::loadBgPalette(ctx, 0, palette));
|
||||
OX_RETURN_ERROR(core::loadBgTileSheet(ctx, 0, m_sceneStatic.tilesheet));
|
||||
OX_RETURN_ERROR(core::loadBgPalette(ctx, 0, palette));
|
||||
// disable all backgrounds
|
||||
gfx::setBgStatus(ctx, 0);
|
||||
core::setBgStatus(ctx, 0);
|
||||
for (auto layerNo = 0u; auto const&layer : m_sceneStatic.tileMapIdx) {
|
||||
setupLayer(ctx, layer, layerNo);
|
||||
++layerNo;
|
||||
@ -29,20 +29,20 @@ ox::Error Scene::setupDisplay(gfx::Context &ctx) const noexcept {
|
||||
}
|
||||
|
||||
void Scene::setupLayer(
|
||||
gfx::Context &ctx,
|
||||
core::Context &ctx,
|
||||
ox::Vector<uint16_t> const&layer,
|
||||
unsigned layerNo) const noexcept {
|
||||
gfx::setBgStatus(ctx, layerNo, true);
|
||||
gfx::setBgCbb(ctx, layerNo, 0);
|
||||
core::setBgStatus(ctx, layerNo, true);
|
||||
core::setBgCbb(ctx, layerNo, 0);
|
||||
auto x = 0;
|
||||
auto y = 0;
|
||||
const auto width = m_sceneStatic.rows[layerNo];
|
||||
for (auto const&tile : layer) {
|
||||
const auto tile8 = static_cast<uint8_t>(tile);
|
||||
gfx::setBgTile(ctx, layerNo, x, y, tile8);
|
||||
gfx::setBgTile(ctx, layerNo, x + 1, y, tile8 + 1);
|
||||
gfx::setBgTile(ctx, layerNo, x, y + 1, tile8 + 2);
|
||||
gfx::setBgTile(ctx, layerNo, x + 1, y + 1, tile8 + 3);
|
||||
core::setBgTile(ctx, layerNo, x, y, tile8);
|
||||
core::setBgTile(ctx, layerNo, x + 1, y, tile8 + 1);
|
||||
core::setBgTile(ctx, layerNo, x, y + 1, tile8 + 2);
|
||||
core::setBgTile(ctx, layerNo, x + 1, y + 1, tile8 + 3);
|
||||
x += 2;
|
||||
if (x >= width * 2) {
|
||||
x = 0;
|
||||
|
@ -2,31 +2,31 @@
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
|
||||
#include "sceneeditorview.hpp"
|
||||
|
||||
namespace nostalgia::scene {
|
||||
|
||||
SceneEditorView::SceneEditorView(turbine::Context &tctx, SceneStatic const&sceneStatic):
|
||||
m_cctx(gfx::init(tctx, {.glInstallDrawer = false}).unwrapThrow()),
|
||||
m_cctx(core::init(tctx, {.glInstallDrawer = false}).unwrapThrow()),
|
||||
m_sceneStatic(sceneStatic),
|
||||
m_scene(m_sceneStatic) {
|
||||
}
|
||||
|
||||
ox::Error SceneEditorView::setupScene() noexcept {
|
||||
glutils::resizeInitFrameBuffer(m_frameBuffer, gfx::gl::drawSize(m_scale));
|
||||
glutils::resizeInitFrameBuffer(m_frameBuffer, core::gl::drawSize(m_scale));
|
||||
return m_scene.setupDisplay(*m_cctx);
|
||||
}
|
||||
|
||||
void SceneEditorView::draw(ox::Size const&targetSz) noexcept {
|
||||
auto const scaleSz = targetSz / gfx::gl::drawSize(1);
|
||||
auto const scaleSz = targetSz / core::gl::drawSize(1);
|
||||
if (m_scaleSz != scaleSz) [[unlikely]] {
|
||||
m_scale = ox::max(1, ox::max(scaleSz.width, scaleSz.height));
|
||||
glutils::resizeInitFrameBuffer(m_frameBuffer, gfx::gl::drawSize(m_scale));
|
||||
glutils::resizeInitFrameBuffer(m_frameBuffer, core::gl::drawSize(m_scale));
|
||||
}
|
||||
glutils::FrameBufferBind const frameBufferBind(m_frameBuffer);
|
||||
gfx::gl::draw(*m_cctx, m_scale);
|
||||
core::gl::draw(*m_cctx, m_scale);
|
||||
}
|
||||
|
||||
glutils::FrameBuffer const&SceneEditorView::framebuffer() const noexcept {
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
#include <glutils/glutils.hpp>
|
||||
|
||||
#include <nostalgia/gfx/context.hpp>
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/scene/scene.hpp>
|
||||
|
||||
namespace nostalgia::scene {
|
||||
@ -15,12 +15,12 @@ namespace nostalgia::scene {
|
||||
class SceneEditorView {
|
||||
|
||||
private:
|
||||
gfx::ContextUPtr m_cctx;
|
||||
core::ContextUPtr m_cctx;
|
||||
SceneStatic const&m_sceneStatic;
|
||||
Scene m_scene;
|
||||
glutils::FrameBuffer m_frameBuffer;
|
||||
int m_scale = 1;
|
||||
ox::Size m_scaleSz = gfx::gl::drawSize(m_scale);
|
||||
ox::Size m_scaleSz = core::gl::drawSize(m_scale);
|
||||
|
||||
public:
|
||||
SceneEditorView(turbine::Context &ctx, SceneStatic const&sceneStatic);
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <studioapp/studioapp.hpp>
|
||||
|
||||
#include <nostalgia/gfx/studiomodule.hpp>
|
||||
#include <nostalgia/core/studiomodule.hpp>
|
||||
#include <nostalgia/scene/studiomodule.hpp>
|
||||
|
||||
namespace nostalgia {
|
||||
@ -15,7 +15,7 @@ void registerStudioModules() noexcept {
|
||||
return;
|
||||
}
|
||||
modulesRegistered = true;
|
||||
studio::registerModule(gfx::studioModule());
|
||||
studio::registerModule(core::studioModule());
|
||||
studio::registerModule(scene::studioModule());
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <keel/media.hpp>
|
||||
#include <turbine/turbine.hpp>
|
||||
|
||||
#include <nostalgia/gfx/core.hpp>
|
||||
#include <nostalgia/core/core.hpp>
|
||||
#include <nostalgia/scene/scene.hpp>
|
||||
|
||||
using namespace nostalgia;
|
||||
@ -16,7 +16,7 @@ static bool s_paused = false;
|
||||
|
||||
[[maybe_unused]]
|
||||
static int testUpdateHandler(turbine::Context &tctx) noexcept {
|
||||
auto &cctx = *turbine::applicationData<gfx::Context>(tctx);
|
||||
auto &cctx = *turbine::applicationData<core::Context>(tctx);
|
||||
constexpr auto sleepTime = 16;
|
||||
if (s_paused) {
|
||||
return sleepTime;
|
||||
@ -41,7 +41,7 @@ static int testUpdateHandler(turbine::Context &tctx) noexcept {
|
||||
constexpr ox::StringView sprites = "nostalgia";
|
||||
for (unsigned i = 0; i < sprites.len(); ++i) {
|
||||
auto const c = static_cast<unsigned>(sprites[i] - ('a' - 1));
|
||||
gfx::setSprite(cctx, i, {
|
||||
core::setSprite(cctx, i, {
|
||||
.enabled = true,
|
||||
.x = spriteX + 8 * (static_cast<int>(i) + 1),
|
||||
.y = spriteY,
|
||||
@ -67,13 +67,13 @@ static void testKeyEventHandler(turbine::Context &tctx, turbine::Key key, bool d
|
||||
static ox::Error runTest(turbine::Context &tctx) {
|
||||
constexpr ox::StringView TileSheetAddr{"/TileSheets/Charset.ng"};
|
||||
constexpr ox::StringView PaletteAddr{"/Palettes/Chester.npal"};
|
||||
OX_REQUIRE_M(cctx, gfx::init(tctx));
|
||||
OX_REQUIRE_M(cctx, core::init(tctx));
|
||||
turbine::setApplicationData(tctx, cctx.get());
|
||||
OX_REQUIRE(tsStat, turbine::rom(tctx)->stat(PaletteAddr));
|
||||
OX_RETURN_ERROR(gfx::loadSpriteTileSheet(*cctx, TileSheetAddr));
|
||||
OX_RETURN_ERROR(gfx::loadSpritePalette(*cctx, PaletteAddr));
|
||||
OX_RETURN_ERROR(gfx::initConsole(*cctx));
|
||||
gfx::puts(*cctx, 10, 9, "DOPENESS!!!");
|
||||
OX_RETURN_ERROR(core::loadSpriteTileSheet(*cctx, TileSheetAddr));
|
||||
OX_RETURN_ERROR(core::loadSpritePalette(*cctx, PaletteAddr));
|
||||
OX_RETURN_ERROR(core::initConsole(*cctx));
|
||||
core::puts(*cctx, 10, 9, "DOPENESS!!!");
|
||||
turbine::setUpdateHandler(tctx, testUpdateHandler);
|
||||
turbine::setKeyEventHandler(tctx, testKeyEventHandler);
|
||||
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
|
||||
// and the first B being backwards
|
||||
constexpr ox::StringView PaletteAddr{"/Palettes/Charset.npal"};
|
||||
OX_REQUIRE_M(cctx, gfx::init(tctx));
|
||||
OX_REQUIRE_M(cctx, core::init(tctx));
|
||||
turbine::setApplicationData(tctx, cctx.get());
|
||||
OX_REQUIRE(tsStat, turbine::rom(tctx)->stat(PaletteAddr));
|
||||
gfx::TileSheetSet const set{
|
||||
core::TileSheetSet const set{
|
||||
.bpp = 4,
|
||||
.entries = {
|
||||
{ .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;
|
||||
OX_RETURN_ERROR(gfx::loadBgTileSheet(*cctx, 0, set));
|
||||
OX_RETURN_ERROR(gfx::loadSpriteTileSheet(*cctx, set));
|
||||
OX_RETURN_ERROR(gfx::loadBgPalette(*cctx, bgPalBank, PaletteAddr));
|
||||
OX_RETURN_ERROR(gfx::loadBgPalette(*cctx, 0, PaletteAddr));
|
||||
OX_RETURN_ERROR(gfx::loadSpritePalette(*cctx, PaletteAddr));
|
||||
gfx::setBgStatus(*cctx, 0, true);
|
||||
gfx::setBgTile(*cctx, 0, 10, 9, { .tileIdx = 1, .palBank = bgPalBank, .flipX = 0, .flipY = 1 });
|
||||
gfx::setBgTile(*cctx, 0, 11, 9, { .tileIdx = 2, .palBank = bgPalBank, .flipX = 1, .flipY = 0 });
|
||||
gfx::setBgTile(*cctx, 0, 13, 9, { .tileIdx = 4, .palBank = bgPalBank, .flipX = 0, .flipY = 0 });
|
||||
gfx::setSprite(*cctx, 16, {
|
||||
OX_RETURN_ERROR(core::loadBgTileSheet(*cctx, 0, set));
|
||||
OX_RETURN_ERROR(core::loadSpriteTileSheet(*cctx, set));
|
||||
OX_RETURN_ERROR(core::loadBgPalette(*cctx, bgPalBank, PaletteAddr));
|
||||
OX_RETURN_ERROR(core::loadBgPalette(*cctx, 0, PaletteAddr));
|
||||
OX_RETURN_ERROR(core::loadSpritePalette(*cctx, PaletteAddr));
|
||||
core::setBgStatus(*cctx, 0, true);
|
||||
core::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 });
|
||||
core::setBgTile(*cctx, 0, 13, 9, { .tileIdx = 4, .palBank = bgPalBank, .flipX = 0, .flipY = 0 });
|
||||
core::setSprite(*cctx, 16, {
|
||||
.enabled = true,
|
||||
.x = 12 * 8,
|
||||
.y = 9 * 8,
|
||||
.tileIdx = 3,
|
||||
.bpp = static_cast<unsigned>(set.bpp),
|
||||
});
|
||||
gfx::setSprite(*cctx, 17, {
|
||||
core::setSprite(*cctx, 17, {
|
||||
.enabled = true,
|
||||
.x = 14 * 8,
|
||||
.y = 9 * 8,
|
||||
@ -148,7 +148,7 @@ static void sceneKeyEventHandler(turbine::Context &tctx, turbine::Key key, bool
|
||||
[[maybe_unused]]
|
||||
static ox::Error runScene(turbine::Context &tctx) {
|
||||
constexpr ox::StringView SceneAddr{"/Scenes/Chester.nscn"};
|
||||
OX_REQUIRE_M(cctx, gfx::init(tctx));
|
||||
OX_REQUIRE_M(cctx, core::init(tctx));
|
||||
OX_REQUIRE(scn, keel::readObj<scene::SceneStatic>(keelCtx(tctx), SceneAddr));
|
||||
turbine::setUpdateHandler(tctx, sceneUpdateHandler);
|
||||
turbine::setKeyEventHandler(tctx, sceneKeyEventHandler);
|
||||
|
Loading…
Reference in New Issue
Block a user