[nostalgia,olympic] Change macro names to comply with broader conventions
This commit is contained in:
@@ -32,18 +32,18 @@ struct Sprite {
|
||||
unsigned priority = 0;
|
||||
};
|
||||
|
||||
oxModelBegin(Sprite)
|
||||
oxModelField(idx)
|
||||
oxModelField(x)
|
||||
oxModelField(y)
|
||||
oxModelField(enabled)
|
||||
oxModelField(tileIdx)
|
||||
oxModelField(spriteShape)
|
||||
oxModelField(spriteSize)
|
||||
oxModelField(flipX)
|
||||
oxModelField(bpp)
|
||||
oxModelField(priority)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(Sprite)
|
||||
OX_MODEL_FIELD(idx)
|
||||
OX_MODEL_FIELD(x)
|
||||
OX_MODEL_FIELD(y)
|
||||
OX_MODEL_FIELD(enabled)
|
||||
OX_MODEL_FIELD(tileIdx)
|
||||
OX_MODEL_FIELD(spriteShape)
|
||||
OX_MODEL_FIELD(spriteSize)
|
||||
OX_MODEL_FIELD(flipX)
|
||||
OX_MODEL_FIELD(bpp)
|
||||
OX_MODEL_FIELD(priority)
|
||||
OX_MODEL_END()
|
||||
|
||||
struct BgTile {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.BgTile";
|
||||
@@ -54,12 +54,12 @@ struct BgTile {
|
||||
unsigned flipY = false;
|
||||
};
|
||||
|
||||
oxModelBegin(BgTile)
|
||||
oxModelField(tileIdx)
|
||||
oxModelField(palBank)
|
||||
oxModelField(horizontalFlip)
|
||||
oxModelField(verticalFlip)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(BgTile)
|
||||
OX_MODEL_FIELD(tileIdx)
|
||||
OX_MODEL_FIELD(palBank)
|
||||
OX_MODEL_FIELD(horizontalFlip)
|
||||
OX_MODEL_FIELD(verticalFlip)
|
||||
OX_MODEL_END()
|
||||
|
||||
struct TileSheetSetEntrySection {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSetEntrySection";
|
||||
@@ -72,10 +72,10 @@ struct TileSheetSetEntrySection {
|
||||
}
|
||||
};
|
||||
|
||||
oxModelBegin(TileSheetSetEntrySection)
|
||||
oxModelField(begin)
|
||||
oxModelField(tiles)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(TileSheetSetEntrySection)
|
||||
OX_MODEL_FIELD(begin)
|
||||
OX_MODEL_FIELD(tiles)
|
||||
OX_MODEL_END()
|
||||
|
||||
struct TileSheetSetEntry {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSetEntry";
|
||||
@@ -84,10 +84,10 @@ struct TileSheetSetEntry {
|
||||
ox::Vector<TileSheetSetEntrySection> sections;
|
||||
};
|
||||
|
||||
oxModelBegin(TileSheetSetEntry)
|
||||
oxModelField(tilesheet)
|
||||
oxModelField(sections)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(TileSheetSetEntry)
|
||||
OX_MODEL_FIELD(tilesheet)
|
||||
OX_MODEL_FIELD(sections)
|
||||
OX_MODEL_END()
|
||||
|
||||
struct TileSheetSet {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSet";
|
||||
@@ -97,10 +97,10 @@ struct TileSheetSet {
|
||||
ox::Vector<TileSheetSetEntry> entries;
|
||||
};
|
||||
|
||||
oxModelBegin(TileSheetSet)
|
||||
oxModelField(bpp)
|
||||
oxModelField(entries)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(TileSheetSet)
|
||||
OX_MODEL_FIELD(bpp)
|
||||
OX_MODEL_FIELD(entries)
|
||||
OX_MODEL_END()
|
||||
|
||||
void addEntry(TileSheetSet &set, ox::FileAddress path, int32_t begin = 0, int32_t size = -1) noexcept;
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ struct PaletteColorV1 {
|
||||
constexpr operator Color16() const noexcept { return color16(r, g, b, a); }
|
||||
};
|
||||
|
||||
oxModelBegin(PaletteColorV1)
|
||||
oxModelField(r)
|
||||
oxModelField(g)
|
||||
oxModelField(b)
|
||||
oxModelField(a)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(PaletteColorV1)
|
||||
OX_MODEL_FIELD(r)
|
||||
OX_MODEL_FIELD(g)
|
||||
OX_MODEL_FIELD(b)
|
||||
OX_MODEL_FIELD(a)
|
||||
OX_MODEL_END()
|
||||
|
||||
using PaletteColor = PaletteColorV1;
|
||||
|
||||
@@ -53,10 +53,10 @@ struct PalettePageV1 {
|
||||
}
|
||||
};
|
||||
|
||||
oxModelBegin(PalettePageV1)
|
||||
oxModelField(name)
|
||||
oxModelField(colors)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(PalettePageV1)
|
||||
OX_MODEL_FIELD(name)
|
||||
OX_MODEL_FIELD(colors)
|
||||
OX_MODEL_END()
|
||||
|
||||
using PalettePage = PalettePageV1;
|
||||
|
||||
@@ -67,9 +67,9 @@ struct NostalgiaPalette {
|
||||
ox::Vector<Color16> colors = {};
|
||||
};
|
||||
|
||||
oxModelBegin(NostalgiaPalette)
|
||||
oxModelField(colors)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(NostalgiaPalette)
|
||||
OX_MODEL_FIELD(colors)
|
||||
OX_MODEL_END()
|
||||
|
||||
|
||||
struct PaletteV1 {
|
||||
@@ -78,9 +78,9 @@ struct PaletteV1 {
|
||||
ox::Vector<Color16> colors;
|
||||
};
|
||||
|
||||
oxModelBegin(PaletteV1)
|
||||
oxModelField(colors)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(PaletteV1)
|
||||
OX_MODEL_FIELD(colors)
|
||||
OX_MODEL_END()
|
||||
|
||||
|
||||
struct PaletteV2 {
|
||||
@@ -90,9 +90,9 @@ struct PaletteV2 {
|
||||
ox::Vector<ox::Vector<Color16>> pages;
|
||||
};
|
||||
|
||||
oxModelBegin(PaletteV2)
|
||||
oxModelField(pages)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(PaletteV2)
|
||||
OX_MODEL_FIELD(pages)
|
||||
OX_MODEL_END()
|
||||
|
||||
|
||||
struct PaletteV3 {
|
||||
@@ -110,14 +110,14 @@ struct PaletteV3 {
|
||||
ox::Vector<ox::Vector<Color16>> pages;
|
||||
};
|
||||
|
||||
oxModelBegin(PaletteV3::ColorInfo)
|
||||
oxModelField(name)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(PaletteV3::ColorInfo)
|
||||
OX_MODEL_FIELD(name)
|
||||
OX_MODEL_END()
|
||||
|
||||
oxModelBegin(PaletteV3)
|
||||
oxModelField(colorInfo)
|
||||
oxModelField(pages)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(PaletteV3)
|
||||
OX_MODEL_FIELD(colorInfo)
|
||||
OX_MODEL_FIELD(pages)
|
||||
OX_MODEL_END()
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool valid(PaletteV3 const&p) noexcept {
|
||||
@@ -144,10 +144,10 @@ struct PaletteV4 {
|
||||
ox::Vector<PalettePageV1> pages;
|
||||
};
|
||||
|
||||
oxModelBegin(PaletteV4)
|
||||
oxModelField(colorNames)
|
||||
oxModelField(pages)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(PaletteV4)
|
||||
OX_MODEL_FIELD(colorNames)
|
||||
OX_MODEL_FIELD(pages)
|
||||
OX_MODEL_END()
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool valid(PaletteV4 const&p) noexcept {
|
||||
@@ -176,9 +176,9 @@ struct CompactPaletteV1 {
|
||||
ox::Vector<ox::Vector<Color16>> pages{};
|
||||
};
|
||||
|
||||
oxModelBegin(CompactPaletteV1)
|
||||
oxModelField(pages)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(CompactPaletteV1)
|
||||
OX_MODEL_FIELD(pages)
|
||||
OX_MODEL_END()
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool valid(CompactPaletteV1 const&p) noexcept {
|
||||
|
||||
@@ -437,65 +437,65 @@ ox::Pair<uint8_t> get2Pixels8Bpp(
|
||||
CompactTileSheet const&ts,
|
||||
size_t idx) noexcept;
|
||||
|
||||
oxModelBegin(TileSheetV1)
|
||||
oxModelField(bpp)
|
||||
oxModelField(rows)
|
||||
oxModelField(columns)
|
||||
oxModelField(defaultPalette)
|
||||
oxModelField(pal)
|
||||
oxModelField(pixels)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(TileSheetV1)
|
||||
OX_MODEL_FIELD(bpp)
|
||||
OX_MODEL_FIELD(rows)
|
||||
OX_MODEL_FIELD(columns)
|
||||
OX_MODEL_FIELD(defaultPalette)
|
||||
OX_MODEL_FIELD(pal)
|
||||
OX_MODEL_FIELD(pixels)
|
||||
OX_MODEL_END()
|
||||
|
||||
oxModelBegin(TileSheetV2::SubSheet)
|
||||
oxModelField(name)
|
||||
oxModelField(rows)
|
||||
oxModelField(columns)
|
||||
oxModelField(subsheets)
|
||||
oxModelField(pixels)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(TileSheetV2::SubSheet)
|
||||
OX_MODEL_FIELD(name)
|
||||
OX_MODEL_FIELD(rows)
|
||||
OX_MODEL_FIELD(columns)
|
||||
OX_MODEL_FIELD(subsheets)
|
||||
OX_MODEL_FIELD(pixels)
|
||||
OX_MODEL_END()
|
||||
|
||||
oxModelBegin(TileSheetV2)
|
||||
oxModelField(bpp)
|
||||
oxModelField(defaultPalette)
|
||||
oxModelField(subsheet)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(TileSheetV2)
|
||||
OX_MODEL_FIELD(bpp)
|
||||
OX_MODEL_FIELD(defaultPalette)
|
||||
OX_MODEL_FIELD(subsheet)
|
||||
OX_MODEL_END()
|
||||
|
||||
oxModelBegin(TileSheetV3::SubSheet)
|
||||
oxModelField(name)
|
||||
oxModelField(rows)
|
||||
oxModelField(columns)
|
||||
oxModelField(subsheets)
|
||||
oxModelField(pixels)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(TileSheetV3::SubSheet)
|
||||
OX_MODEL_FIELD(name)
|
||||
OX_MODEL_FIELD(rows)
|
||||
OX_MODEL_FIELD(columns)
|
||||
OX_MODEL_FIELD(subsheets)
|
||||
OX_MODEL_FIELD(pixels)
|
||||
OX_MODEL_END()
|
||||
|
||||
oxModelBegin(TileSheetV3)
|
||||
oxModelField(bpp)
|
||||
oxModelField(idIt)
|
||||
oxModelField(defaultPalette)
|
||||
oxModelField(subsheet)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(TileSheetV3)
|
||||
OX_MODEL_FIELD(bpp)
|
||||
OX_MODEL_FIELD(idIt)
|
||||
OX_MODEL_FIELD(defaultPalette)
|
||||
OX_MODEL_FIELD(subsheet)
|
||||
OX_MODEL_END()
|
||||
|
||||
oxModelBegin(TileSheetV4::SubSheet)
|
||||
oxModelField(id)
|
||||
oxModelField(name)
|
||||
oxModelField(rows)
|
||||
oxModelField(columns)
|
||||
oxModelField(subsheets)
|
||||
oxModelField(pixels)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(TileSheetV4::SubSheet)
|
||||
OX_MODEL_FIELD(id)
|
||||
OX_MODEL_FIELD(name)
|
||||
OX_MODEL_FIELD(rows)
|
||||
OX_MODEL_FIELD(columns)
|
||||
OX_MODEL_FIELD(subsheets)
|
||||
OX_MODEL_FIELD(pixels)
|
||||
OX_MODEL_END()
|
||||
|
||||
oxModelBegin(TileSheetV4)
|
||||
oxModelField(bpp)
|
||||
oxModelField(idIt)
|
||||
oxModelField(defaultPalette)
|
||||
oxModelField(subsheet)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(TileSheetV4)
|
||||
OX_MODEL_FIELD(bpp)
|
||||
OX_MODEL_FIELD(idIt)
|
||||
OX_MODEL_FIELD(defaultPalette)
|
||||
OX_MODEL_FIELD(subsheet)
|
||||
OX_MODEL_END()
|
||||
|
||||
oxModelBegin(CompactTileSheetV1)
|
||||
oxModelField(bpp)
|
||||
oxModelField(defaultPalette)
|
||||
oxModelField(pixels)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(CompactTileSheetV1)
|
||||
OX_MODEL_FIELD(bpp)
|
||||
OX_MODEL_FIELD(defaultPalette)
|
||||
OX_MODEL_FIELD(pixels)
|
||||
OX_MODEL_END()
|
||||
|
||||
ox::Vector<uint32_t> resizeTileSheetData(
|
||||
ox::Vector<uint32_t> const&srcPixels,
|
||||
|
||||
@@ -21,7 +21,7 @@ ox::Error initGfx(Context &ctx, InitParams const&) noexcept;
|
||||
|
||||
ox::Result<ContextUPtr> init(turbine::Context &tctx, InitParams const¶ms) noexcept {
|
||||
auto ctx = ox::make_unique<Context>(tctx);
|
||||
oxReturnError(initGfx(*ctx, params));
|
||||
OX_RETURN_ERROR(initGfx(*ctx, params));
|
||||
return ContextUPtr(std::move(ctx));
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ static ox::Error loadTileSheetSet(
|
||||
size_t tileWriteIdx = 0;
|
||||
size_t const bppMod = set.bpp == 4;
|
||||
for (auto const&entry : set.entries) {
|
||||
oxRequire(ts, keel::readObj<CompactTileSheet>(keelCtx(ctx), entry.tilesheet));
|
||||
OX_REQUIRE(ts, keel::readObj<CompactTileSheet>(keelCtx(ctx), entry.tilesheet));
|
||||
if (set.bpp != ts->bpp && ts->bpp == 8) {
|
||||
return ox::Error(1, "cannot load an 8 BPP tilesheet into a 4 BPP CBB");
|
||||
}
|
||||
@@ -138,7 +138,7 @@ ox::Error loadBgTileSheet(
|
||||
}
|
||||
});
|
||||
if (paletteBank.has_value() && ts.defaultPalette) {
|
||||
oxReturnError(loadBgPalette(ctx, *paletteBank, ts.defaultPalette));
|
||||
OX_RETURN_ERROR(loadBgPalette(ctx, *paletteBank, ts.defaultPalette));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -148,7 +148,7 @@ ox::Error loadBgTileSheet(
|
||||
unsigned const cbb,
|
||||
TileSheetSet const&set) noexcept {
|
||||
auto const bpp = static_cast<unsigned>(set.bpp);
|
||||
oxReturnError(loadTileSheetSet(ctx, MEM_BG_TILES[cbb], set));
|
||||
OX_RETURN_ERROR(loadTileSheetSet(ctx, MEM_BG_TILES[cbb], set));
|
||||
// update bpp of all bgs with the updated cbb
|
||||
ctx.cbbData[cbb].bpp = bpp;
|
||||
teagba::iterateBgCtl([bpp, cbb](volatile BgCtl &bgCtl) {
|
||||
@@ -178,7 +178,7 @@ ox::Error loadSpriteTileSheet(
|
||||
MEM_SPRITE_TILES[i] = v;
|
||||
}
|
||||
if (loadDefaultPalette && ts.defaultPalette) {
|
||||
oxReturnError(loadSpritePalette(ctx, ts.defaultPalette));
|
||||
OX_RETURN_ERROR(loadSpritePalette(ctx, ts.defaultPalette));
|
||||
}
|
||||
setSpritesBpp(static_cast<unsigned>(ts.bpp));
|
||||
return {};
|
||||
@@ -188,7 +188,7 @@ ox::Error loadSpriteTileSheet(
|
||||
Context &ctx,
|
||||
TileSheetSet const&set) noexcept {
|
||||
auto const bpp = static_cast<unsigned>(set.bpp);
|
||||
oxReturnError(loadTileSheetSet(ctx, {MEM_SPRITE_TILES, 32 * ox::units::KB}, set));
|
||||
OX_RETURN_ERROR(loadTileSheetSet(ctx, {MEM_SPRITE_TILES, 32 * ox::units::KB}, set));
|
||||
setSpritesBpp(bpp);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ ox::Error loadBgPalette(
|
||||
Context &ctx,
|
||||
size_t palBank,
|
||||
ox::StringViewCR palettePath) noexcept {
|
||||
oxRequire(pal, keel::readObj<CompactPalette>(keelCtx(ctx), palettePath));
|
||||
OX_REQUIRE(pal, keel::readObj<CompactPalette>(keelCtx(ctx), palettePath));
|
||||
return loadBgPalette(ctx, palBank, *pal, 0);
|
||||
}
|
||||
|
||||
@@ -30,21 +30,21 @@ ox::Error loadBgPalette(
|
||||
Context &ctx,
|
||||
size_t palBank,
|
||||
ox::FileAddress const&paletteAddr) noexcept {
|
||||
oxRequire(pal, keel::readObj<CompactPalette>(keelCtx(ctx), paletteAddr));
|
||||
OX_REQUIRE(pal, keel::readObj<CompactPalette>(keelCtx(ctx), paletteAddr));
|
||||
return loadBgPalette(ctx, palBank, *pal, 0);
|
||||
}
|
||||
|
||||
ox::Error loadSpritePalette(
|
||||
Context &ctx,
|
||||
ox::StringViewCR palettePath) noexcept {
|
||||
oxRequire(pal, keel::readObj<CompactPalette>(keelCtx(ctx), palettePath));
|
||||
OX_REQUIRE(pal, keel::readObj<CompactPalette>(keelCtx(ctx), palettePath));
|
||||
return loadSpritePalette(ctx, *pal, 0);
|
||||
}
|
||||
|
||||
ox::Error loadSpritePalette(
|
||||
Context &ctx,
|
||||
ox::FileAddress const&paletteAddr) noexcept {
|
||||
oxRequire(pal, keel::readObj<CompactPalette>(keelCtx(ctx), paletteAddr));
|
||||
OX_REQUIRE(pal, keel::readObj<CompactPalette>(keelCtx(ctx), paletteAddr));
|
||||
return loadSpritePalette(ctx, *pal, 0);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ ox::Error loadBgTileSheet(
|
||||
size_t dstTileIdx,
|
||||
size_t srcTileIdx,
|
||||
size_t tileCnt) noexcept {
|
||||
oxRequire(ts, keel::readObj<CompactTileSheet>(keelCtx(ctx), tsAddr));
|
||||
OX_REQUIRE(ts, keel::readObj<CompactTileSheet>(keelCtx(ctx), tsAddr));
|
||||
return loadBgTileSheet(ctx, cbb, *ts, dstTileIdx, srcTileIdx, tileCnt);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ ox::Error loadBgTileSheet(
|
||||
size_t dstTileIdx,
|
||||
size_t srcTileIdx,
|
||||
size_t tileCnt) noexcept {
|
||||
oxRequire(ts, keel::readObj<CompactTileSheet>(keelCtx(ctx), tsPath));
|
||||
OX_REQUIRE(ts, keel::readObj<CompactTileSheet>(keelCtx(ctx), tsPath));
|
||||
return loadBgTileSheet(ctx, cbb, *ts, dstTileIdx, srcTileIdx, tileCnt);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ ox::Error loadBgTileSheet(
|
||||
unsigned cbb,
|
||||
ox::StringViewCR tilesheetPath,
|
||||
ox::Optional<unsigned> const&paletteBank) noexcept {
|
||||
oxRequire(ts, keel::readObj<CompactTileSheet>(keelCtx(ctx), tilesheetPath));
|
||||
OX_REQUIRE(ts, keel::readObj<CompactTileSheet>(keelCtx(ctx), tilesheetPath));
|
||||
return loadBgTileSheet(ctx, cbb, *ts, paletteBank);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ ox::Error loadBgTileSheet(
|
||||
unsigned cbb,
|
||||
ox::FileAddress const&tilesheetAddr,
|
||||
ox::Optional<unsigned> const&paletteBank) noexcept {
|
||||
oxRequire(ts, keel::readObj<CompactTileSheet>(keelCtx(ctx), tilesheetAddr));
|
||||
OX_REQUIRE(ts, keel::readObj<CompactTileSheet>(keelCtx(ctx), tilesheetAddr));
|
||||
return loadBgTileSheet(ctx, cbb, *ts, paletteBank);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ ox::Error loadSpriteTileSheet(
|
||||
Context &ctx,
|
||||
ox::StringViewCR tilesheetPath,
|
||||
bool loadDefaultPalette) noexcept {
|
||||
oxRequire(ts, readObj<CompactTileSheet>(keelCtx(ctx), tilesheetPath));
|
||||
OX_REQUIRE(ts, readObj<CompactTileSheet>(keelCtx(ctx), tilesheetPath));
|
||||
return loadSpriteTileSheet(ctx, *ts, loadDefaultPalette);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ ox::Error loadSpriteTileSheet(
|
||||
Context &ctx,
|
||||
ox::FileAddress const&tilesheetAddr,
|
||||
bool loadDefaultPalette) noexcept {
|
||||
oxRequire(ts, readObj<CompactTileSheet>(keelCtx(ctx), tilesheetAddr));
|
||||
OX_REQUIRE(ts, readObj<CompactTileSheet>(keelCtx(ctx), tilesheetAddr));
|
||||
return loadSpriteTileSheet(ctx, *ts, loadDefaultPalette);
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ ox::Error initConsole(Context &ctx) noexcept {
|
||||
constexpr ox::FileAddress PaletteAddr = ox::StringLiteral("/Palettes/Charset.npal");
|
||||
setBgStatus(ctx, 0b0001);
|
||||
setBgCbb(ctx, 0, 0);
|
||||
oxReturnError(loadBgTileSheet(ctx, 0, TilesheetAddr));
|
||||
OX_RETURN_ERROR(loadBgTileSheet(ctx, 0, TilesheetAddr));
|
||||
return loadBgPalette(ctx, 0, PaletteAddr);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ static class: public keel::Module {
|
||||
typeId == ox::ModelTypeId_v<TileSheetV2> ||
|
||||
typeId == ox::ModelTypeId_v<TileSheetV3> ||
|
||||
typeId == ox::ModelTypeId_v<TileSheetV4>) {
|
||||
oxReturnError(keel::convertBuffToBuff<CompactTileSheet>(
|
||||
OX_RETURN_ERROR(keel::convertBuffToBuff<CompactTileSheet>(
|
||||
ctx, buff, ox::ClawFormat::Metal).moveTo(buff));
|
||||
return true;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ static class: public keel::Module {
|
||||
typeId == ox::ModelTypeId_v<PaletteV2> ||
|
||||
typeId == ox::ModelTypeId_v<PaletteV3> ||
|
||||
typeId == ox::ModelTypeId_v<PaletteV4>) {
|
||||
oxReturnError(keel::convertBuffToBuff<CompactPalette>(
|
||||
OX_RETURN_ERROR(keel::convertBuffToBuff<CompactPalette>(
|
||||
ctx, buff, ox::ClawFormat::Metal).moveTo(buff));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ Context::~Context() noexcept {
|
||||
|
||||
ox::Result<ContextUPtr> init(turbine::Context &tctx, InitParams const¶ms) noexcept {
|
||||
auto ctx = ox::make_unique<Context>(tctx, params);
|
||||
oxReturnError(initGfx(*ctx, params));
|
||||
OX_RETURN_ERROR(initGfx(*ctx, params));
|
||||
return ContextUPtr(ctx.release());
|
||||
}
|
||||
|
||||
|
||||
@@ -464,8 +464,8 @@ ox::Error initGfx(
|
||||
const auto bgFshad = ox::sfmt(renderer::bgfshadTmpl, gl::GlslVersion);
|
||||
const auto spriteVshad = ox::sfmt(renderer::spritevshadTmpl, gl::GlslVersion);
|
||||
const auto spriteFshad = ox::sfmt(renderer::spritefshadTmpl, gl::GlslVersion);
|
||||
oxReturnError(glutils::buildShaderProgram(bgVshad, bgFshad).moveTo(ctx.bgShader));
|
||||
oxReturnError(
|
||||
OX_RETURN_ERROR(glutils::buildShaderProgram(bgVshad, bgFshad).moveTo(ctx.bgShader));
|
||||
OX_RETURN_ERROR(
|
||||
glutils::buildShaderProgram(spriteVshad, spriteFshad).moveTo(ctx.spriteShader));
|
||||
for (auto &cbb : ctx.cbbs) {
|
||||
initBackgroundBufferset(ctx.bgShader, cbb);
|
||||
@@ -538,8 +538,8 @@ static ox::Result<TileSheetData> buildSetTsd(
|
||||
TileSheetData setTsd;
|
||||
setTsd.width = TileWidth;
|
||||
for (auto const&entry : set.entries) {
|
||||
oxRequire(tilesheet, readObj<CompactTileSheet>(kctx, entry.tilesheet));
|
||||
oxRequire(tsd, normalizeTileSheet(*tilesheet));
|
||||
OX_REQUIRE(tilesheet, readObj<CompactTileSheet>(kctx, entry.tilesheet));
|
||||
OX_REQUIRE(tsd, normalizeTileSheet(*tilesheet));
|
||||
for (auto const&s : entry.sections) {
|
||||
auto const size = s.tiles * PixelsPerTile;
|
||||
for (auto i = 0; i < size; ++i) {
|
||||
@@ -604,9 +604,9 @@ ox::Error loadBgTileSheet(
|
||||
ox::Optional<unsigned> const&paletteBank) noexcept {
|
||||
auto const bytesPerTile = static_cast<uint64_t>(PixelsPerTile / (1 + (ts.bpp == 4)));
|
||||
auto const tiles = ts.pixels.size() / bytesPerTile;
|
||||
oxReturnError(loadBgTileSheet(ctx, cbb, ts, 0, 0, tiles));
|
||||
OX_RETURN_ERROR(loadBgTileSheet(ctx, cbb, ts, 0, 0, tiles));
|
||||
if (paletteBank.has_value() && ts.defaultPalette) {
|
||||
oxReturnError(loadBgPalette(ctx, *paletteBank, ts.defaultPalette));
|
||||
OX_RETURN_ERROR(loadBgPalette(ctx, *paletteBank, ts.defaultPalette));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -615,7 +615,7 @@ ox::Error loadBgTileSheet(
|
||||
Context &ctx,
|
||||
unsigned cbb,
|
||||
TileSheetSet const&set) noexcept {
|
||||
oxRequire(setTsd, buildSetTsd(ctx, set));
|
||||
OX_REQUIRE(setTsd, buildSetTsd(ctx, set));
|
||||
ctx.cbbs[cbb].tex = renderer::createTexture(setTsd.width, setTsd.height, setTsd.pixels.data());
|
||||
return {};
|
||||
}
|
||||
@@ -624,11 +624,11 @@ ox::Error loadSpriteTileSheet(
|
||||
Context &ctx,
|
||||
CompactTileSheet const&ts,
|
||||
bool loadDefaultPalette) noexcept {
|
||||
oxRequire(tsd, normalizeTileSheet(ts));
|
||||
OX_REQUIRE(tsd, normalizeTileSheet(ts));
|
||||
oxTracef("nostalgia.core.gfx.gl", "loadSpriteTexture: { w: {}, h: {} }", tsd.width, tsd.height);
|
||||
ctx.spriteBlocks.tex = renderer::createTexture(tsd.width, tsd.height, tsd.pixels.data());
|
||||
if (loadDefaultPalette) {
|
||||
oxReturnError(loadSpritePalette(ctx, ts.defaultPalette));
|
||||
OX_RETURN_ERROR(loadSpritePalette(ctx, ts.defaultPalette));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -636,7 +636,7 @@ ox::Error loadSpriteTileSheet(
|
||||
ox::Error loadSpriteTileSheet(
|
||||
Context &ctx,
|
||||
TileSheetSet const&set) noexcept {
|
||||
oxRequire(setTsd, buildSetTsd(ctx, set));
|
||||
OX_REQUIRE(setTsd, buildSetTsd(ctx, set));
|
||||
ctx.spriteBlocks.tex = renderer::createTexture(setTsd.width, setTsd.height, setTsd.pixels.data());
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ ox::Error AddColorCommand::redo() noexcept {
|
||||
}
|
||||
|
||||
ox::Error AddColorCommand::undo() noexcept {
|
||||
oxReturnError(m_pal.colorNames.erase(m_idx));
|
||||
OX_RETURN_ERROR(m_pal.colorNames.erase(m_idx));
|
||||
for (auto &page : m_pal.pages) {
|
||||
oxReturnError(page.colors.erase(m_idx));
|
||||
OX_RETURN_ERROR(page.colors.erase(m_idx));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ int RemoveColorCommand::commandId() const noexcept {
|
||||
|
||||
ox::Error RemoveColorCommand::redo() noexcept {
|
||||
m_colorInfo = std::move(m_pal.colorNames[m_idx]);
|
||||
oxReturnError(m_pal.colorNames.erase(m_idx));
|
||||
OX_RETURN_ERROR(m_pal.colorNames.erase(m_idx));
|
||||
for (auto &page : m_pal.pages) {
|
||||
oxReturnError(page.colors.erase(m_idx));
|
||||
OX_RETURN_ERROR(page.colors.erase(m_idx));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ ox::Error AddSubSheetCommand::undo() noexcept {
|
||||
--m_img.idIt;
|
||||
} else {
|
||||
for (auto idx = m_addedSheets.rbegin(); idx != m_addedSheets.rend(); ++idx) {
|
||||
oxReturnError(rmSubSheet(m_img, *idx));
|
||||
OX_RETURN_ERROR(rmSubSheet(m_img, *idx));
|
||||
--m_img.idIt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
|
||||
namespace nostalgia::core {
|
||||
|
||||
oxModelFwdDecl(class TileSheetClipboard);
|
||||
OX_MODEL_FWD_DECL(class TileSheetClipboard);
|
||||
|
||||
class TileSheetClipboard: public turbine::ClipboardObject<TileSheetClipboard> {
|
||||
public:
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.TileSheetClipboard";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
|
||||
oxModelFriend(TileSheetClipboard);
|
||||
OX_MODEL_FRIEND(TileSheetClipboard);
|
||||
|
||||
struct Pixel {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.TileSheetClipboard.Pixel";
|
||||
@@ -36,14 +36,14 @@ class TileSheetClipboard: public turbine::ClipboardObject<TileSheetClipboard> {
|
||||
ox::Vector<Pixel> const&pixels() const noexcept;
|
||||
};
|
||||
|
||||
oxModelBegin(TileSheetClipboard::Pixel)
|
||||
oxModelField(colorIdx)
|
||||
oxModelField(pt)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(TileSheetClipboard::Pixel)
|
||||
OX_MODEL_FIELD(colorIdx)
|
||||
OX_MODEL_FIELD(pt)
|
||||
OX_MODEL_END()
|
||||
|
||||
oxModelBegin(TileSheetClipboard)
|
||||
oxModelFieldRename(m_pixels, pixels)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(TileSheetClipboard)
|
||||
OX_MODEL_FIELD_RENAME(m_pixels, pixels)
|
||||
OX_MODEL_END()
|
||||
|
||||
class CutPasteCommand: public TileSheetCommand {
|
||||
private:
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ core::RmSubSheetCommand::RmSubSheetCommand(TileSheet &img, TileSheet::SubSheetId
|
||||
ox::Error RmSubSheetCommand::redo() noexcept {
|
||||
auto &parent = getSubSheet(m_img, m_parentIdx);
|
||||
m_sheet = std::move(parent.subsheets[*m_idx.back().value]);
|
||||
oxReturnError(parent.subsheets.erase(*m_idx.back().value).error);
|
||||
OX_RETURN_ERROR(parent.subsheets.erase(*m_idx.back().value).error);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ struct TileSheetEditorConfig {
|
||||
TileSheet::SubSheetIdx activeSubsheet{};
|
||||
};
|
||||
|
||||
oxModelBegin(TileSheetEditorConfig)
|
||||
oxModelFieldRename(activeSubsheet, active_subsheet)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(TileSheetEditorConfig)
|
||||
OX_MODEL_FIELD_RENAME(activeSubsheet, active_subsheet)
|
||||
OX_MODEL_END()
|
||||
|
||||
static ox::Vector<uint32_t> normalizePixelSizes(
|
||||
ox::Vector<uint8_t> const&inPixels,
|
||||
@@ -346,7 +346,7 @@ void TileSheetEditorImGui::showSubsheetEditor() noexcept {
|
||||
}
|
||||
|
||||
ox::Error TileSheetEditorImGui::exportSubhseetToPng(int const scale) const noexcept {
|
||||
oxRequire(path, studio::saveFile({{"PNG", "png"}}));
|
||||
OX_REQUIRE(path, studio::saveFile({{"PNG", "png"}}));
|
||||
// subsheet to png
|
||||
auto const&img = m_model.img();
|
||||
auto const&s = m_model.activeSubSheet();
|
||||
|
||||
@@ -132,7 +132,7 @@ ox::StringView TileSheetEditorModel::palPath() const noexcept {
|
||||
}
|
||||
|
||||
ox::Error TileSheetEditorModel::setPalette(ox::StringView path) noexcept {
|
||||
oxRequire(uuid, keelCtx(m_tctx).pathToUuid.at(path));
|
||||
OX_REQUIRE(uuid, keelCtx(m_tctx).pathToUuid.at(path));
|
||||
pushCommand(ox::make<PaletteChangeCommand>(activeSubSheetIdx(), m_img, uuid->toString()));
|
||||
return {};
|
||||
}
|
||||
@@ -250,7 +250,7 @@ ox::Error TileSheetEditorModel::markUpdatedCmdId(studio::UndoCommand const*cmd)
|
||||
m_updated = true;
|
||||
const auto cmdId = cmd->commandId();
|
||||
if (static_cast<CommandId>(cmdId) == CommandId::PaletteChange) {
|
||||
oxReturnError(readObj<Palette>(keelCtx(m_tctx), m_img.defaultPalette).moveTo(m_pal));
|
||||
OX_RETURN_ERROR(readObj<Palette>(keelCtx(m_tctx), m_img.defaultPalette).moveTo(m_pal));
|
||||
m_palettePage = ox::min<size_t>(m_pal->pages.size(), 0);
|
||||
paletteChanged.emit();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ TileSheetEditorView::TileSheetEditorView(studio::StudioContext &sctx, ox::String
|
||||
m_pixelsDrawer(m_model) {
|
||||
glBindVertexArray(0);
|
||||
// build shaders
|
||||
oxThrowError(m_pixelsDrawer.buildShader());
|
||||
oxThrowError(m_pixelGridDrawer.buildShader());
|
||||
OX_THROW_ERROR(m_pixelsDrawer.buildShader());
|
||||
OX_THROW_ERROR(m_pixelGridDrawer.buildShader());
|
||||
m_model.activeSubsheetChanged.connect(this, &TileSheetEditorView::setActiveSubsheet);
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ unsigned pixelCnt(TileSheet::SubSheet const&ss, int8_t pBpp) noexcept {
|
||||
|
||||
ox::Error resizeSubsheet(TileSheet::SubSheet &ss, int8_t pBpp, ox::Size const&sz) noexcept {
|
||||
ox::Vector<uint8_t> out;
|
||||
oxReturnError(setPixelCount(out, pBpp, static_cast<size_t>(sz.width * sz.height) * PixelsPerTile));
|
||||
OX_RETURN_ERROR(setPixelCount(out, pBpp, static_cast<size_t>(sz.width * sz.height) * PixelsPerTile));
|
||||
auto const w = ox::min<int32_t>(ss.columns, sz.width) * TileWidth;
|
||||
auto const h = ox::min<int32_t>(ss.rows, sz.height) * TileHeight;
|
||||
for (auto x = 0; x < w; ++x) {
|
||||
|
||||
@@ -16,8 +16,8 @@ static std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
"readWriteTileSheet",
|
||||
[]() -> ox::Error {
|
||||
core::TileSheet in;
|
||||
oxRequire(buff, ox::writeMC(in));
|
||||
oxRequire(out, ox::readMC<core::TileSheet>(buff));
|
||||
OX_REQUIRE(buff, ox::writeMC(in));
|
||||
OX_REQUIRE(out, ox::readMC<core::TileSheet>(buff));
|
||||
oxAssert(in.subsheet.name == out.subsheet.name, "subsheet.name serialization broken");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -57,12 +57,12 @@ struct TileDoc {
|
||||
|
||||
};
|
||||
|
||||
oxModelBegin(TileDoc)
|
||||
oxModelFieldRename(subsheetId, subsheet_id)
|
||||
oxModelFieldRename(subsheetPath, subsheet_path)
|
||||
oxModelField(type)
|
||||
oxModelFieldRename(layerAttachments, layer_attachments)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(TileDoc)
|
||||
OX_MODEL_FIELD_RENAME(subsheetId, subsheet_id)
|
||||
OX_MODEL_FIELD_RENAME(subsheetPath, subsheet_path)
|
||||
OX_MODEL_FIELD(type)
|
||||
OX_MODEL_FIELD_RENAME(layerAttachments, layer_attachments)
|
||||
OX_MODEL_END()
|
||||
|
||||
struct SceneDoc {
|
||||
|
||||
@@ -95,11 +95,11 @@ struct SceneDoc {
|
||||
}
|
||||
};
|
||||
|
||||
oxModelBegin(SceneDoc)
|
||||
oxModelField(tilesheet)
|
||||
oxModelField(palettes)
|
||||
oxModelField(tiles)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(SceneDoc)
|
||||
OX_MODEL_FIELD(tilesheet)
|
||||
OX_MODEL_FIELD(palettes)
|
||||
OX_MODEL_FIELD(tiles)
|
||||
OX_MODEL_END()
|
||||
|
||||
|
||||
constexpr void setTopEdge(uint8_t &layerAttachments, unsigned val) noexcept {
|
||||
@@ -215,14 +215,14 @@ struct SceneStatic {
|
||||
|
||||
};
|
||||
|
||||
oxModelBegin(SceneStatic)
|
||||
oxModelField(tilesheet)
|
||||
oxModelField(palettes)
|
||||
oxModelField(columns)
|
||||
oxModelField(rows)
|
||||
oxModelField(tileMapIdx)
|
||||
oxModelField(tileType)
|
||||
oxModelField(layerAttachments)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(SceneStatic)
|
||||
OX_MODEL_FIELD(tilesheet)
|
||||
OX_MODEL_FIELD(palettes)
|
||||
OX_MODEL_FIELD(columns)
|
||||
OX_MODEL_FIELD(rows)
|
||||
OX_MODEL_FIELD(tileMapIdx)
|
||||
OX_MODEL_FIELD(tileType)
|
||||
OX_MODEL_FIELD(layerAttachments)
|
||||
OX_MODEL_END()
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ ox::Error SceneDocToSceneStaticConverter::convert(
|
||||
keel::Context &ctx,
|
||||
SceneDoc &src,
|
||||
SceneStatic &dst) const noexcept {
|
||||
oxRequire(ts, keel::readObj<core::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);
|
||||
@@ -53,8 +53,8 @@ ox::Error SceneDocToSceneStaticConverter::convert(
|
||||
for (const auto &srcTile : row) {
|
||||
auto dstTile = dstLayer.tile(tileIdx);
|
||||
dstTile.tileType = srcTile.type;
|
||||
oxRequire(path, srcTile.getSubsheetPath(*ts));
|
||||
oxRequire(mapIdx, getTileOffset(*ts, path));
|
||||
OX_REQUIRE(path, srcTile.getSubsheetPath(*ts));
|
||||
OX_REQUIRE(mapIdx, getTileOffset(*ts, path));
|
||||
dstTile.tileMapIdx = static_cast<uint16_t>(mapIdx);
|
||||
setLayerAttachments(layerIdx, srcTile, dstTile);
|
||||
++tileIdx;
|
||||
|
||||
@@ -17,8 +17,8 @@ ox::Error Scene::setupDisplay(core::Context &ctx) const noexcept {
|
||||
return ox::Error(1, "Scene has no palettes");
|
||||
}
|
||||
auto const&palette = m_sceneStatic.palettes[0];
|
||||
oxReturnError(core::loadBgTileSheet(ctx, 0, m_sceneStatic.tilesheet));
|
||||
oxReturnError(core::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
|
||||
core::setBgStatus(ctx, 0);
|
||||
for (auto layerNo = 0u; auto const&layer : m_sceneStatic.tileMapIdx) {
|
||||
|
||||
@@ -48,7 +48,7 @@ void SceneEditorImGui::onActivated() noexcept {
|
||||
|
||||
ox::Error SceneEditorImGui::saveItem() noexcept {
|
||||
const auto sctx = applicationData<studio::StudioContext>(m_ctx);
|
||||
oxReturnError(sctx->project->writeObj(itemPath(), m_editor.scene()));
|
||||
OX_RETURN_ERROR(sctx->project->writeObj(itemPath(), m_editor.scene()));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user