Compare commits
No commits in common. "d4eaade3269bc91e18caf7e11647dc4a83e870c2" and "56e980385cc89dd630e6ae8558c5c0d3f5a59a3c" have entirely different histories.
d4eaade326
...
56e980385c
@ -48,6 +48,8 @@ bool bgStatus(Context *ctx, unsigned bg) noexcept;
|
|||||||
|
|
||||||
void setBgStatus(Context *ctx, unsigned bg, bool status) noexcept;
|
void setBgStatus(Context *ctx, unsigned bg, bool status) noexcept;
|
||||||
|
|
||||||
|
ox::Error initConsole(Context *ctx) noexcept;
|
||||||
|
|
||||||
void setBgCbb(Context *ctx, unsigned bgIdx, unsigned cbb) noexcept;
|
void setBgCbb(Context *ctx, unsigned bgIdx, unsigned cbb) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,8 +62,6 @@ ox::Error loadSpriteTileSheet(Context *ctx,
|
|||||||
const ox::FileAddress &tilesheetAddr,
|
const ox::FileAddress &tilesheetAddr,
|
||||||
const ox::FileAddress &paletteAddr) noexcept;
|
const ox::FileAddress &paletteAddr) noexcept;
|
||||||
|
|
||||||
ox::Error initConsole(Context *ctx) noexcept;
|
|
||||||
|
|
||||||
void puts(Context *ctx, int column, int row, ox::CRStringView str) noexcept;
|
void puts(Context *ctx, int column, int row, ox::CRStringView str) noexcept;
|
||||||
|
|
||||||
void setTile(Context *ctx, unsigned bgIdx, int column, int row, uint8_t tile) noexcept;
|
void setTile(Context *ctx, unsigned bgIdx, int column, int row, uint8_t tile) noexcept;
|
||||||
|
@ -8,13 +8,11 @@
|
|||||||
|
|
||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
GbaContext::GbaContext(turbine::Context *tctx) noexcept: turbineCtx(tctx) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ox::Error initGfx(Context *ctx, const InitParams&) noexcept;
|
ox::Error initGfx(Context *ctx, const InitParams&) noexcept;
|
||||||
|
|
||||||
ox::Result<ox::UniquePtr<Context>> init(turbine::Context *tctx, const InitParams ¶ms) noexcept {
|
ox::Result<ox::UniquePtr<Context>> init(turbine::Context *tctx, const InitParams ¶ms) noexcept {
|
||||||
auto ctx = ox::make_unique<GbaContext>(tctx);
|
auto ctx = ox::make_unique<GbaContext>();
|
||||||
|
ctx->turbineCtx = tctx;
|
||||||
oxReturnError(initGfx(ctx.get(), params));
|
oxReturnError(initGfx(ctx.get(), params));
|
||||||
return ox::UPtr<Context>(ctx.release());
|
return ox::UPtr<Context>(ctx.release());
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@ namespace nostalgia::core {
|
|||||||
|
|
||||||
struct GbaContext: public core::Context {
|
struct GbaContext: public core::Context {
|
||||||
|
|
||||||
turbine::Context const*turbineCtx = nullptr;
|
turbine::Context *turbineCtx = nullptr;
|
||||||
|
|
||||||
explicit GbaContext(turbine::Context *tctx) noexcept;
|
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
const auto &rom() const noexcept {
|
const auto &rom() const noexcept {
|
||||||
|
@ -80,7 +80,7 @@ void shutdownGfx(Context*) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t bgStatus(Context*) noexcept {
|
uint8_t bgStatus(Context*) noexcept {
|
||||||
return (REG_DISPCTL >> 8u) & 0b1111u;
|
return (REG_DISPCTL >> 8) & 0b1111;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBgStatus(Context*, uint32_t status) noexcept {
|
void setBgStatus(Context*, uint32_t status) noexcept {
|
||||||
@ -98,6 +98,28 @@ void setBgStatus(Context*, unsigned bg, bool status) noexcept {
|
|||||||
REG_DISPCTL = REG_DISPCTL | ((REG_DISPCTL & ~mask) | mask);
|
REG_DISPCTL = REG_DISPCTL | ((REG_DISPCTL & ~mask) | mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do NOT rely on Context in the GBA version of this function.
|
||||||
|
ox::Error initConsole(Context *ctx) noexcept {
|
||||||
|
constexpr ox::FileAddress TilesheetAddr("/TileSheets/Charset.ng");
|
||||||
|
constexpr ox::FileAddress PaletteAddr("/Palettes/Charset.npal");
|
||||||
|
setBgStatus(ctx, 0b0001);
|
||||||
|
if (!ctx) {
|
||||||
|
const auto gctx = new(ox_alloca(sizeof(GbaContext))) GbaContext;
|
||||||
|
oxRequire(rom, keel::loadRom());
|
||||||
|
auto romFs = new(ox_alloca(sizeof(ox::FileSystem32)))
|
||||||
|
ox::FileSystem32(ox::FileStore32(rom, 32 * ox::units::MB));
|
||||||
|
oxRequireM(tctx, turbine::init(ox::UPtr<ox::FileSystem>(romFs), ""));
|
||||||
|
gctx->turbineCtx = tctx.release();
|
||||||
|
oxReturnError(loadBgTileSheet(gctx, 0, TilesheetAddr, PaletteAddr));
|
||||||
|
setBgCbb(gctx, 0, 0);
|
||||||
|
return {};
|
||||||
|
} else {
|
||||||
|
oxReturnError(loadBgTileSheet(ctx, 0, TilesheetAddr, PaletteAddr));
|
||||||
|
setBgCbb(ctx, 0, 0);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setBgCbb(Context*, unsigned bgIdx, unsigned cbb) noexcept {
|
void setBgCbb(Context*, unsigned bgIdx, unsigned cbb) noexcept {
|
||||||
auto &bgCtl = regBgCtl(bgIdx);
|
auto &bgCtl = regBgCtl(bgIdx);
|
||||||
const auto &cbbData = g_cbbData[cbb];
|
const auto &cbbData = g_cbbData[cbb];
|
||||||
@ -105,13 +127,13 @@ void setBgCbb(Context*, unsigned bgIdx, unsigned cbb) noexcept {
|
|||||||
teagba::bgSetCbb(&bgCtl, cbb);
|
teagba::bgSetCbb(&bgCtl, cbb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ox::Error loadBgTileSheet(
|
ox::Error loadBgTileSheet(Context *ctx,
|
||||||
const ox::MemFS &rom,
|
unsigned cbb,
|
||||||
unsigned cbb,
|
const ox::FileAddress &tilesheetAddr,
|
||||||
const ox::FileAddress &tilesheetAddr,
|
const ox::FileAddress &paletteAddr) noexcept {
|
||||||
const ox::FileAddress &paletteAddr) noexcept {
|
auto &gctx = static_cast<GbaContext&>(*ctx);
|
||||||
oxRequire(tsStat, rom.stat(tilesheetAddr));
|
oxRequire(tsStat, gctx.rom().stat(tilesheetAddr));
|
||||||
oxRequire(ts, rom.directAccess(tilesheetAddr));
|
oxRequire(ts, static_cast<const ox::MemFS&>(gctx.rom()).directAccess(tilesheetAddr));
|
||||||
GbaTileMapTarget target;
|
GbaTileMapTarget target;
|
||||||
target.pal.palette = MEM_BG_PALETTE;
|
target.pal.palette = MEM_BG_PALETTE;
|
||||||
target.cbbData = &g_cbbData[cbb];
|
target.cbbData = &g_cbbData[cbb];
|
||||||
@ -119,8 +141,8 @@ static ox::Error loadBgTileSheet(
|
|||||||
oxReturnError(ox::readMC(ts, static_cast<std::size_t>(tsStat.size), &target));
|
oxReturnError(ox::readMC(ts, static_cast<std::size_t>(tsStat.size), &target));
|
||||||
// load external palette if available
|
// load external palette if available
|
||||||
if (paletteAddr) {
|
if (paletteAddr) {
|
||||||
oxRequire(palStat, rom.stat(paletteAddr));
|
oxRequire(palStat, gctx.rom().stat(paletteAddr));
|
||||||
oxRequire(pal, rom.directAccess(paletteAddr));
|
oxRequire(pal, static_cast<const ox::MemFS&>(gctx.rom()).directAccess(paletteAddr));
|
||||||
oxReturnError(ox::readMC(pal, static_cast<std::size_t>(palStat.size), &target.pal));
|
oxReturnError(ox::readMC(pal, static_cast<std::size_t>(palStat.size), &target.pal));
|
||||||
}
|
}
|
||||||
// update bpp of all bgs with the updated cbb
|
// update bpp of all bgs with the updated cbb
|
||||||
@ -133,15 +155,6 @@ static ox::Error loadBgTileSheet(
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error loadBgTileSheet(Context *ctx,
|
|
||||||
unsigned cbb,
|
|
||||||
const ox::FileAddress &tilesheetAddr,
|
|
||||||
const ox::FileAddress &paletteAddr) noexcept {
|
|
||||||
auto &gctx = static_cast<GbaContext&>(*ctx);
|
|
||||||
auto &rom = static_cast<const ox::MemFS&>(gctx.rom());
|
|
||||||
return loadBgTileSheet(rom, cbb, tilesheetAddr, paletteAddr);
|
|
||||||
}
|
|
||||||
|
|
||||||
ox::Error loadSpriteTileSheet(Context *ctx,
|
ox::Error loadSpriteTileSheet(Context *ctx,
|
||||||
const ox::FileAddress &tilesheetAddr,
|
const ox::FileAddress &tilesheetAddr,
|
||||||
const ox::FileAddress &paletteAddr) noexcept {
|
const ox::FileAddress &paletteAddr) noexcept {
|
||||||
@ -173,33 +186,14 @@ ox::Error loadBgPalette(Context *ctx, unsigned, const ox::FileAddress &paletteAd
|
|||||||
|
|
||||||
ox::Error loadSpritePalette(Context *ctx, unsigned cbb, const ox::FileAddress &paletteAddr) noexcept {
|
ox::Error loadSpritePalette(Context *ctx, unsigned cbb, const ox::FileAddress &paletteAddr) noexcept {
|
||||||
auto &gctx = static_cast<GbaContext&>(*ctx);
|
auto &gctx = static_cast<GbaContext&>(*ctx);
|
||||||
auto &rom = static_cast<const ox::MemFS&>(gctx.rom());
|
|
||||||
GbaPaletteTarget target;
|
GbaPaletteTarget target;
|
||||||
target.palette = &MEM_SPRITE_PALETTE[cbb];
|
target.palette = &MEM_SPRITE_PALETTE[cbb];
|
||||||
oxRequire(palStat, rom.stat(paletteAddr));
|
oxRequire(palStat, gctx.rom().stat(paletteAddr));
|
||||||
oxRequire(pal, rom.directAccess(paletteAddr));
|
oxRequire(pal, static_cast<const ox::MemFS&>(gctx.rom()).directAccess(paletteAddr));
|
||||||
oxReturnError(ox::readMC(pal, static_cast<std::size_t>(palStat.size), &target));
|
oxReturnError(ox::readMC(pal, static_cast<std::size_t>(palStat.size), &target));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do NOT rely on Context in the GBA version of this function.
|
|
||||||
ox::Error initConsole(Context *ctx) noexcept {
|
|
||||||
constexpr ox::FileAddress TilesheetAddr("/TileSheets/Charset.ng");
|
|
||||||
constexpr ox::FileAddress PaletteAddr("/Palettes/Charset.npal");
|
|
||||||
setBgStatus(ctx, 0b0001);
|
|
||||||
if (!ctx) {
|
|
||||||
oxRequire(rom, keel::loadRom());
|
|
||||||
const ox::FileSystem32 romFs(ox::FileStore32(rom, 32 * ox::units::MB));
|
|
||||||
oxReturnError(loadBgTileSheet(romFs, 0, TilesheetAddr, PaletteAddr));
|
|
||||||
setBgCbb(nullptr, 0, 0);
|
|
||||||
return {};
|
|
||||||
} else {
|
|
||||||
oxReturnError(loadBgTileSheet(ctx, 0, TilesheetAddr, PaletteAddr));
|
|
||||||
setBgCbb(ctx, 0, 0);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void puts(Context *ctx, int column, int row, ox::CRStringView str) noexcept {
|
void puts(Context *ctx, int column, int row, ox::CRStringView str) noexcept {
|
||||||
const auto col = static_cast<unsigned>(column);
|
const auto col = static_cast<unsigned>(column);
|
||||||
for (auto i = 0u; i < str.bytes(); i++) {
|
for (auto i = 0u; i < str.bytes(); i++) {
|
||||||
|
@ -363,6 +363,14 @@ void shutdownGfx(Context &ctx) noexcept {
|
|||||||
turbine::gl::removeDrawer(gctx.turbineCtx, &gctx.drawer);
|
turbine::gl::removeDrawer(gctx.turbineCtx, &gctx.drawer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ox::Error initConsole(Context *ctx) noexcept {
|
||||||
|
constexpr ox::FileAddress TilesheetAddr("/TileSheets/Charset.ng");
|
||||||
|
constexpr ox::FileAddress PaletteAddr("/Palettes/Charset.npal");
|
||||||
|
setBgStatus(ctx, 0b0001);
|
||||||
|
setBgCbb(ctx, 0, 0);
|
||||||
|
return loadBgTileSheet(ctx, 0, TilesheetAddr, PaletteAddr);
|
||||||
|
}
|
||||||
|
|
||||||
struct TileSheetData {
|
struct TileSheetData {
|
||||||
ox::Vector<uint32_t> pixels;
|
ox::Vector<uint32_t> pixels;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
@ -422,14 +430,6 @@ ox::Error loadSpriteTileSheet(
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error initConsole(Context *ctx) noexcept {
|
|
||||||
constexpr ox::FileAddress TilesheetAddr("/TileSheets/Charset.ng");
|
|
||||||
constexpr ox::FileAddress PaletteAddr("/Palettes/Charset.npal");
|
|
||||||
setBgStatus(ctx, 0b0001);
|
|
||||||
setBgCbb(ctx, 0, 0);
|
|
||||||
return loadBgTileSheet(ctx, 0, TilesheetAddr, PaletteAddr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void puts(Context *ctx, int column, int row, ox::CRStringView str) noexcept {
|
void puts(Context *ctx, int column, int row, ox::CRStringView str) noexcept {
|
||||||
const auto col = static_cast<unsigned>(column);
|
const auto col = static_cast<unsigned>(column);
|
||||||
for (auto i = 0u; i < str.bytes(); ++i) {
|
for (auto i = 0u; i < str.bytes(); ++i) {
|
||||||
|
@ -22,13 +22,6 @@ target_include_directories(
|
|||||||
../include
|
../include
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
|
||||||
DIRECTORY
|
|
||||||
../include/studioapp
|
|
||||||
DESTINATION
|
|
||||||
include
|
|
||||||
)
|
|
||||||
|
|
||||||
install(
|
install(
|
||||||
TARGETS
|
TARGETS
|
||||||
StudioAppLib
|
StudioAppLib
|
||||||
|
@ -12,6 +12,18 @@ add_library(
|
|||||||
filedialog_nfd.cpp
|
filedialog_nfd.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(NOT MSVC)
|
||||||
|
target_compile_options(Studio PUBLIC -Wsign-conversion)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(
|
||||||
|
TARGETS
|
||||||
|
Studio
|
||||||
|
DESTINATION
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
)
|
||||||
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
Studio PUBLIC
|
Studio PUBLIC
|
||||||
../include
|
../include
|
||||||
@ -30,16 +42,19 @@ target_link_libraries(
|
|||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
TARGETS
|
FILES
|
||||||
Studio
|
../include/studio/configio.hpp
|
||||||
DESTINATION
|
../include/studio/context.hpp
|
||||||
LIBRARY DESTINATION lib
|
../include/studio/editor.hpp
|
||||||
ARCHIVE DESTINATION lib
|
../include/studio/filedialog.hpp
|
||||||
)
|
../include/studio/itemmaker.hpp
|
||||||
|
../include/studio/module.hpp
|
||||||
install(
|
../include/studio/popup.hpp
|
||||||
DIRECTORY
|
../include/studio/project.hpp
|
||||||
../include/studio
|
../include/studio/studio.hpp
|
||||||
|
../include/studio/task.hpp
|
||||||
|
../include/studio/undostack.hpp
|
||||||
|
../include/studio/widget.hpp
|
||||||
DESTINATION
|
DESTINATION
|
||||||
include/studio/
|
include/studio/
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user