Compare commits
1 Commits
master
...
david/clar
| Author | SHA1 | Date | |
|---|---|---|---|
| e07cfc8ec3 |
2
deps/ox/src/ox/clargs/clargs.cpp
vendored
2
deps/ox/src/ox/clargs/clargs.cpp
vendored
@@ -40,7 +40,7 @@ ClArgs::ClArgs(ox::SpanView<const char*> args) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ClArgs::getBool(ox::StringViewCR arg, bool defaultValue) const noexcept {
|
bool ClArgs::getBool(ox::StringViewCR arg, bool defaultValue) const noexcept {
|
||||||
auto const [value, err] = m_ints.at(arg);
|
auto const [value, err] = m_bools.at(arg);
|
||||||
return !err ? *value : defaultValue;
|
return !err ? *value : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
20
deps/teagba/include/teagba/addresses.hpp
vendored
20
deps/teagba/include/teagba/addresses.hpp
vendored
@@ -99,23 +99,23 @@ volatile OffsetPair ®BgOfs(auto const bgIdx) noexcept {
|
|||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// Memory Addresses
|
// Memory Addresses
|
||||||
|
|
||||||
#define MEM_EWRAM (*(reinterpret_cast<ox::Array<uint16_t, 0x0203'FFFF - 0x0200'0000>*>(0x0200'0000)))
|
#define MEM_EWRAM (*reinterpret_cast<ox::Array<uint16_t, 0x0203'FFFF - 0x0200'0000>*>(0x0200'0000))
|
||||||
|
|
||||||
#define MEM_IWRAM (*(reinterpret_cast<ox::Array<uint8_t, 0x0300'7FFF - 0x0300'0000>*>(0x0300'0000)))
|
#define MEM_IWRAM (*reinterpret_cast<ox::Array<uint8_t, 0x0300'7FFF - 0x0300'0000>*>(0x0300'0000))
|
||||||
|
|
||||||
#define REG_BLNDCTL (*reinterpret_cast<uint16_t*>(0x0400'0050))
|
#define REG_BLNDCTL (*reinterpret_cast<uint16_t*>(0x0400'0050))
|
||||||
|
|
||||||
using Palette = ox::Array<uint16_t, 128>;
|
using Palette = ox::Array<uint16_t, 128>;
|
||||||
#define MEM_BG_PALETTE (*(reinterpret_cast<::Palette*>(0x0500'0000)))
|
#define MEM_BG_PALETTE (*reinterpret_cast<::Palette*>(0x0500'0000))
|
||||||
#define MEM_SPRITE_PALETTE (*(reinterpret_cast<::Palette*>(0x0500'0200)))
|
#define MEM_SPRITE_PALETTE (*reinterpret_cast<::Palette*>(0x0500'0200))
|
||||||
|
|
||||||
using BgMapTile = ox::Array<uint16_t, 8192>;
|
using BgMapTile = ox::Array<uint16_t, 8192>;
|
||||||
#define MEM_BG_TILES (*(reinterpret_cast<ox::Array<BgMapTile, 4>*>(0x0600'0000)))
|
#define MEM_BG_TILES (*reinterpret_cast<ox::Array<BgMapTile, 4>*>(0x0600'0000))
|
||||||
#define MEM_BG_MAP (*(reinterpret_cast<ox::Array<BgMapTile, 4>*>(0x0600'e000)))
|
#define MEM_BG_MAP (*reinterpret_cast<ox::Array<BgMapTile, 4>*>(0x0600'e000))
|
||||||
|
|
||||||
#define MEM_SPRITE_TILES (*(reinterpret_cast<ox::Array<uint16_t, 32 * ox::units::KB>*>(0x0601'0000)))
|
#define MEM_SPRITE_TILES (*reinterpret_cast<ox::Array<uint16_t, 32 * ox::units::KB>*>(0x0601'0000))
|
||||||
#define MEM_OAM (*(reinterpret_cast<ox::Array<uint64_t, 64>*>(0x0700'0000)))
|
#define MEM_OAM (*reinterpret_cast<ox::Array<uint64_t, 64>*>(0x0700'0000))
|
||||||
|
|
||||||
#define MEM_ROM (*(reinterpret_cast<ox::Array<char, 32 * ox::units::MB>*>(0x0700'0000)))
|
#define MEM_ROM (*reinterpret_cast<ox::Array<char, 32 * ox::units::MB>*>(0x0700'0000))
|
||||||
|
|
||||||
#define MEM_SRAM (*(reinterpret_cast<ox::Array<char, 64 * ox::units::KB>*>(0x0e00'0000)))
|
#define MEM_SRAM (*reinterpret_cast<ox::Array<char, 64 * ox::units::KB>*>(0x0e00'0000))
|
||||||
|
|||||||
2
deps/teagba/include/teagba/gfx.hpp
vendored
2
deps/teagba/include/teagba/gfx.hpp
vendored
@@ -43,4 +43,6 @@ void applySpriteUpdates() noexcept;
|
|||||||
|
|
||||||
void setBgOffset(uint16_t bg, int16_t x, int16_t y) noexcept;
|
void setBgOffset(uint16_t bg, int16_t x, int16_t y) noexcept;
|
||||||
|
|
||||||
|
void scrollBgOffset(uint16_t bg, int16_t x, int16_t y) noexcept;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
8
deps/teagba/src/gfx.cpp
vendored
8
deps/teagba/src/gfx.cpp
vendored
@@ -18,7 +18,7 @@ GbaSpriteAttrUpdate &spriteAttr(size_t const i) noexcept {
|
|||||||
|
|
||||||
void addSpriteUpdate(GbaSpriteAttrUpdate const &upd) noexcept {
|
void addSpriteUpdate(GbaSpriteAttrUpdate const &upd) noexcept {
|
||||||
const auto ie = REG_IE; // disable vblank interrupt handler
|
const auto ie = REG_IE; // disable vblank interrupt handler
|
||||||
REG_IE = REG_IE & static_cast<uint16_t>(~Int_vblank); // disable vblank interrupt handler
|
REG_IE = REG_IE & static_cast<uint16_t>(~teagba::Int_vblank); // disable vblank interrupt handler
|
||||||
g_spriteBuffer[upd.idx] = upd;
|
g_spriteBuffer[upd.idx] = upd;
|
||||||
REG_IE = ie; // enable vblank interrupt handler
|
REG_IE = ie; // enable vblank interrupt handler
|
||||||
}
|
}
|
||||||
@@ -35,4 +35,10 @@ void setBgOffset(uint16_t const bg, int16_t const x, int16_t const y) noexcept {
|
|||||||
o.y = y;
|
o.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void scrollBgOffset(uint16_t const bg, int16_t const x, int16_t const y) noexcept {
|
||||||
|
auto &o = regBgOfs(bg);
|
||||||
|
o.x = o.x + x;
|
||||||
|
o.y = o.y + y;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,15 +23,17 @@ struct BgCbbData {
|
|||||||
unsigned bpp = 4;
|
unsigned bpp = 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Context final {
|
class Context {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
turbine::Context &turbineCtx;
|
turbine::Context &turbineCtx;
|
||||||
ox::Array<BgCbbData, 4> cbbData;
|
ox::Array<BgCbbData, 4> cbbData;
|
||||||
ox::Array<OffsetPair, 4> bgOffsets;
|
|
||||||
|
|
||||||
explicit Context(turbine::Context &tctx) noexcept: turbineCtx{tctx} {}
|
explicit Context(turbine::Context &tctx) noexcept: turbineCtx{tctx} {}
|
||||||
|
Context(Context &other) noexcept = delete;
|
||||||
Context(Context const &other) noexcept = delete;
|
Context(Context const &other) noexcept = delete;
|
||||||
|
Context(Context const &&other) noexcept = delete;
|
||||||
|
virtual ~Context() noexcept = default;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -293,16 +295,12 @@ void setBgPriority(Context&, uint_t const bgIdx, uint_t const priority) noexcept
|
|||||||
bgCtl = (bgCtl & 0b1111'1111'1111'1100u) | (priority & 0b11);
|
bgCtl = (bgCtl & 0b1111'1111'1111'1100u) | (priority & 0b11);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBgOffset(Context &ctx, uint16_t const bg, int16_t const x, int16_t const y) noexcept {
|
void setBgOffset(Context&, uint16_t const bg, int16_t const x, int16_t const y) noexcept {
|
||||||
ctx.bgOffsets[bg] = {.x = x, .y = y};
|
|
||||||
teagba::setBgOffset(bg, x, y);
|
teagba::setBgOffset(bg, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrollBgOffset(Context &ctx, uint16_t const bg, int16_t const x, int16_t const y) noexcept {
|
void scrollBgOffset(Context&, uint16_t const bg, int16_t const x, int16_t const y) noexcept {
|
||||||
auto &o = ctx.bgOffsets[bg];
|
teagba::scrollBgOffset(bg, x, y);
|
||||||
o.x += x;
|
|
||||||
o.y += y;
|
|
||||||
teagba::setBgOffset(bg, o.x, o.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void hideSprite(Context&, unsigned const idx) noexcept {
|
void hideSprite(Context&, unsigned const idx) noexcept {
|
||||||
|
|||||||
@@ -87,7 +87,9 @@ class Context {
|
|||||||
blocksPerSprite{params.glBlocksPerSprite} {
|
blocksPerSprite{params.glBlocksPerSprite} {
|
||||||
}
|
}
|
||||||
Context(Context const&) = delete;
|
Context(Context const&) = delete;
|
||||||
|
Context(Context&&) = delete;
|
||||||
Context &operator=(Context const&) = delete;
|
Context &operator=(Context const&) = delete;
|
||||||
|
Context &operator=(Context&&) = delete;
|
||||||
~Context() noexcept {
|
~Context() noexcept {
|
||||||
turbine::gl::removeDrawer(turbineCtx, &drawer);
|
turbine::gl::removeDrawer(turbineCtx, &drawer);
|
||||||
}
|
}
|
||||||
@@ -111,7 +113,7 @@ namespace renderer {
|
|||||||
static constexpr auto Scale = 1;
|
static constexpr auto Scale = 1;
|
||||||
static constexpr auto PriorityScale = 0.01f;
|
static constexpr auto PriorityScale = 0.01f;
|
||||||
|
|
||||||
static constexpr ox::StringLiteral bgvshadTmpl{R"glsl(
|
static constexpr ox::CStringView bgvshadTmpl = R"glsl(
|
||||||
{}
|
{}
|
||||||
in vec2 vTexCoord;
|
in vec2 vTexCoord;
|
||||||
in vec3 vPosition;
|
in vec3 vPosition;
|
||||||
@@ -133,9 +135,9 @@ static constexpr ox::StringLiteral bgvshadTmpl{R"glsl(
|
|||||||
vTexCoord.x,
|
vTexCoord.x,
|
||||||
vTexCoord.y * vTileHeight + vTileIdx * vTileHeight);
|
vTexCoord.y * vTileHeight + vTileIdx * vTileHeight);
|
||||||
fPalOffset = vPalOffset;
|
fPalOffset = vPalOffset;
|
||||||
})glsl"};
|
})glsl";
|
||||||
|
|
||||||
static constexpr ox::StringLiteral bgfshadTmpl{R"glsl(
|
static constexpr ox::CStringView bgfshadTmpl = R"glsl(
|
||||||
{}
|
{}
|
||||||
out vec4 outColor;
|
out vec4 outColor;
|
||||||
in float fPalOffset;
|
in float fPalOffset;
|
||||||
@@ -149,9 +151,9 @@ static constexpr ox::StringLiteral bgfshadTmpl{R"glsl(
|
|||||||
if (outColor.a == 0) {
|
if (outColor.a == 0) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
})glsl"};
|
})glsl";
|
||||||
|
|
||||||
static constexpr ox::StringLiteral spritevshadTmpl{R"glsl(
|
static constexpr ox::CStringView spritevshadTmpl = R"glsl(
|
||||||
{}
|
{}
|
||||||
in float vEnabled;
|
in float vEnabled;
|
||||||
in vec3 vPosition;
|
in vec3 vPosition;
|
||||||
@@ -168,9 +170,9 @@ static constexpr ox::StringLiteral spritevshadTmpl{R"glsl(
|
|||||||
vPosition.z - 0.004,
|
vPosition.z - 0.004,
|
||||||
1.0) * vEnabled;
|
1.0) * vEnabled;
|
||||||
fTexCoord = vTexCoord * vec2(1, vTileHeight);
|
fTexCoord = vTexCoord * vec2(1, vTileHeight);
|
||||||
})glsl"};
|
})glsl";
|
||||||
|
|
||||||
static constexpr ox::StringLiteral spritefshadTmpl{R"glsl(
|
static constexpr ox::CStringView spritefshadTmpl = R"glsl(
|
||||||
{}
|
{}
|
||||||
out vec4 outColor;
|
out vec4 outColor;
|
||||||
in vec2 fTexCoord;
|
in vec2 fTexCoord;
|
||||||
@@ -183,7 +185,7 @@ static constexpr ox::StringLiteral spritefshadTmpl{R"glsl(
|
|||||||
if (outColor.a == 0) {
|
if (outColor.a == 0) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
})glsl"};
|
})glsl";
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
static constexpr auto bgVertexRow(uint_t const x, uint_t const y) noexcept {
|
static constexpr auto bgVertexRow(uint_t const x, uint_t const y) noexcept {
|
||||||
@@ -839,12 +841,6 @@ void setBgPriority(Context &ctx, uint_t const bgIdx, uint_t const priority) noex
|
|||||||
bg.priority = static_cast<float>(priority & 0b11);
|
bg.priority = static_cast<float>(priority & 0b11);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBgOffset(Context&, uint16_t const, int16_t const, int16_t const) noexcept {
|
|
||||||
}
|
|
||||||
|
|
||||||
void scrollBgOffset(Context&, uint16_t const, int16_t const, int16_t const) noexcept {
|
|
||||||
}
|
|
||||||
|
|
||||||
void hideSprite(Context &ctx, uint_t const idx) noexcept {
|
void hideSprite(Context &ctx, uint_t const idx) noexcept {
|
||||||
auto &s = ctx.spriteStates[idx];
|
auto &s = ctx.spriteStates[idx];
|
||||||
s.enabled = false;
|
s.enabled = false;
|
||||||
|
|||||||
@@ -285,11 +285,11 @@ static void handleKeyPress(Context &ctx, int const key, bool const down) noexcep
|
|||||||
map[GLFW_KEY_ESCAPE] = Key::Escape;
|
map[GLFW_KEY_ESCAPE] = Key::Escape;
|
||||||
return map;
|
return map;
|
||||||
}();
|
}();
|
||||||
|
auto const eventHandler = keyEventHandler(ctx);
|
||||||
auto const keyIdx = static_cast<std::size_t>(key);
|
auto const keyIdx = static_cast<std::size_t>(key);
|
||||||
if (keyIdx < keyMap.size()) {
|
if (keyIdx < keyMap.size()) {
|
||||||
auto const k = keyMap[keyIdx];
|
auto const k = keyMap[keyIdx];
|
||||||
setKeyDownStatus(ctx, k, down);
|
setKeyDownStatus(ctx, k, down);
|
||||||
auto const eventHandler = keyEventHandler(ctx);
|
|
||||||
if (eventHandler) {
|
if (eventHandler) {
|
||||||
eventHandler(ctx, k, down);
|
eventHandler(ctx, k, down);
|
||||||
}
|
}
|
||||||
@@ -306,9 +306,7 @@ static void handleGlfwMouseButtonEvent(
|
|||||||
int) noexcept {
|
int) noexcept {
|
||||||
auto &ctx = *static_cast<Context*>(glfwGetWindowUserPointer(window));
|
auto &ctx = *static_cast<Context*>(glfwGetWindowUserPointer(window));
|
||||||
setMandatoryRefreshPeriod(ctx, ticksMs(ctx) + config::MandatoryRefreshPeriod);
|
setMandatoryRefreshPeriod(ctx, ticksMs(ctx) + config::MandatoryRefreshPeriod);
|
||||||
if (ctx.mouseButtonEventHandler) {
|
ctx.mouseButtonEventHandler(ctx, btn, action == 1);
|
||||||
ctx.mouseButtonEventHandler(ctx, btn, action == 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleGlfwKeyEvent(GLFWwindow *window, int const key, int, int const action, int) noexcept {
|
static void handleGlfwKeyEvent(GLFWwindow *window, int const key, int, int const action, int) noexcept {
|
||||||
|
|||||||
Reference in New Issue
Block a user