diff --git a/deps/nostalgia/deps/teagba/include/teagba/addresses.hpp b/deps/nostalgia/deps/teagba/include/teagba/addresses.hpp index 6b2e5e2..168c0d5 100644 --- a/deps/nostalgia/deps/teagba/include/teagba/addresses.hpp +++ b/deps/nostalgia/deps/teagba/include/teagba/addresses.hpp @@ -99,23 +99,23 @@ volatile OffsetPair ®BgOfs(auto const bgIdx) noexcept { ///////////////////////////////////////////////////////////////// // Memory Addresses -#define MEM_EWRAM (*reinterpret_cast*>(0x0200'0000)) +#define MEM_EWRAM (*(reinterpret_cast*>(0x0200'0000))) -#define MEM_IWRAM (*reinterpret_cast*>(0x0300'0000)) +#define MEM_IWRAM (*(reinterpret_cast*>(0x0300'0000))) #define REG_BLNDCTL (*reinterpret_cast(0x0400'0050)) using Palette = ox::Array; -#define MEM_BG_PALETTE (*reinterpret_cast<::Palette*>(0x0500'0000)) -#define MEM_SPRITE_PALETTE (*reinterpret_cast<::Palette*>(0x0500'0200)) +#define MEM_BG_PALETTE (*(reinterpret_cast<::Palette*>(0x0500'0000))) +#define MEM_SPRITE_PALETTE (*(reinterpret_cast<::Palette*>(0x0500'0200))) using BgMapTile = ox::Array; -#define MEM_BG_TILES (*reinterpret_cast*>(0x0600'0000)) -#define MEM_BG_MAP (*reinterpret_cast*>(0x0600'e000)) +#define MEM_BG_TILES (*(reinterpret_cast*>(0x0600'0000))) +#define MEM_BG_MAP (*(reinterpret_cast*>(0x0600'e000))) -#define MEM_SPRITE_TILES (*reinterpret_cast*>(0x0601'0000)) -#define MEM_OAM (*reinterpret_cast*>(0x0700'0000)) +#define MEM_SPRITE_TILES (*(reinterpret_cast*>(0x0601'0000))) +#define MEM_OAM (*(reinterpret_cast*>(0x0700'0000))) -#define MEM_ROM (*reinterpret_cast*>(0x0700'0000)) +#define MEM_ROM (*(reinterpret_cast*>(0x0700'0000))) -#define MEM_SRAM (*reinterpret_cast*>(0x0e00'0000)) +#define MEM_SRAM (*(reinterpret_cast*>(0x0e00'0000))) diff --git a/deps/nostalgia/deps/teagba/include/teagba/gfx.hpp b/deps/nostalgia/deps/teagba/include/teagba/gfx.hpp index 4a25212..3093df8 100644 --- a/deps/nostalgia/deps/teagba/include/teagba/gfx.hpp +++ b/deps/nostalgia/deps/teagba/include/teagba/gfx.hpp @@ -43,6 +43,4 @@ void applySpriteUpdates() 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; - } diff --git a/deps/nostalgia/deps/teagba/src/gfx.cpp b/deps/nostalgia/deps/teagba/src/gfx.cpp index cd1e38b..fde8ec2 100644 --- a/deps/nostalgia/deps/teagba/src/gfx.cpp +++ b/deps/nostalgia/deps/teagba/src/gfx.cpp @@ -18,7 +18,7 @@ GbaSpriteAttrUpdate &spriteAttr(size_t const i) noexcept { void addSpriteUpdate(GbaSpriteAttrUpdate const &upd) noexcept { const auto ie = REG_IE; // disable vblank interrupt handler - REG_IE = REG_IE & static_cast(~teagba::Int_vblank); // disable vblank interrupt handler + REG_IE = REG_IE & static_cast(~Int_vblank); // disable vblank interrupt handler g_spriteBuffer[upd.idx] = upd; REG_IE = ie; // enable vblank interrupt handler } @@ -35,10 +35,4 @@ void setBgOffset(uint16_t const bg, int16_t const x, int16_t const y) noexcept { 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; -} - } diff --git a/deps/nostalgia/src/nostalgia/modules/gfx/src/gfx-gba.cpp b/deps/nostalgia/src/nostalgia/modules/gfx/src/gfx-gba.cpp index a1d6ba4..766f74b 100644 --- a/deps/nostalgia/src/nostalgia/modules/gfx/src/gfx-gba.cpp +++ b/deps/nostalgia/src/nostalgia/modules/gfx/src/gfx-gba.cpp @@ -23,17 +23,15 @@ struct BgCbbData { unsigned bpp = 4; }; -class Context { +class Context final { public: turbine::Context &turbineCtx; ox::Array cbbData; + ox::Array bgOffsets; 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; - virtual ~Context() noexcept = default; }; @@ -295,12 +293,16 @@ void setBgPriority(Context&, uint_t const bgIdx, uint_t const priority) noexcept bgCtl = (bgCtl & 0b1111'1111'1111'1100u) | (priority & 0b11); } -void setBgOffset(Context&, uint16_t const bg, int16_t const x, int16_t const y) noexcept { +void setBgOffset(Context &ctx, 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); } -void scrollBgOffset(Context&, uint16_t const bg, int16_t const x, int16_t const y) noexcept { - teagba::scrollBgOffset(bg, x, y); +void scrollBgOffset(Context &ctx, uint16_t const bg, int16_t const x, int16_t const y) noexcept { + auto &o = ctx.bgOffsets[bg]; + o.x += x; + o.y += y; + teagba::setBgOffset(bg, o.x, o.y); } void hideSprite(Context&, unsigned const idx) noexcept { diff --git a/deps/nostalgia/src/nostalgia/modules/gfx/src/gfx-opengl.cpp b/deps/nostalgia/src/nostalgia/modules/gfx/src/gfx-opengl.cpp index 778b451..c3acefc 100644 --- a/deps/nostalgia/src/nostalgia/modules/gfx/src/gfx-opengl.cpp +++ b/deps/nostalgia/src/nostalgia/modules/gfx/src/gfx-opengl.cpp @@ -87,9 +87,7 @@ class Context { blocksPerSprite{params.glBlocksPerSprite} { } Context(Context const&) = delete; - Context(Context&&) = delete; Context &operator=(Context const&) = delete; - Context &operator=(Context&&) = delete; ~Context() noexcept { turbine::gl::removeDrawer(turbineCtx, &drawer); } @@ -113,7 +111,7 @@ namespace renderer { static constexpr auto Scale = 1; static constexpr auto PriorityScale = 0.01f; -static constexpr ox::CStringView bgvshadTmpl = R"glsl( +static constexpr ox::StringLiteral bgvshadTmpl{R"glsl( {} in vec2 vTexCoord; in vec3 vPosition; @@ -135,9 +133,9 @@ static constexpr ox::CStringView bgvshadTmpl = R"glsl( vTexCoord.x, vTexCoord.y * vTileHeight + vTileIdx * vTileHeight); fPalOffset = vPalOffset; - })glsl"; + })glsl"}; -static constexpr ox::CStringView bgfshadTmpl = R"glsl( +static constexpr ox::StringLiteral bgfshadTmpl{R"glsl( {} out vec4 outColor; in float fPalOffset; @@ -151,9 +149,9 @@ static constexpr ox::CStringView bgfshadTmpl = R"glsl( if (outColor.a == 0) { discard; } - })glsl"; + })glsl"}; -static constexpr ox::CStringView spritevshadTmpl = R"glsl( +static constexpr ox::StringLiteral spritevshadTmpl{R"glsl( {} in float vEnabled; in vec3 vPosition; @@ -170,9 +168,9 @@ static constexpr ox::CStringView spritevshadTmpl = R"glsl( vPosition.z - 0.004, 1.0) * vEnabled; fTexCoord = vTexCoord * vec2(1, vTileHeight); - })glsl"; + })glsl"}; -static constexpr ox::CStringView spritefshadTmpl = R"glsl( +static constexpr ox::StringLiteral spritefshadTmpl{R"glsl( {} out vec4 outColor; in vec2 fTexCoord; @@ -185,7 +183,7 @@ static constexpr ox::CStringView spritefshadTmpl = R"glsl( if (outColor.a == 0) { discard; } - })glsl"; + })glsl"}; [[nodiscard]] static constexpr auto bgVertexRow(uint_t const x, uint_t const y) noexcept { @@ -841,6 +839,12 @@ void setBgPriority(Context &ctx, uint_t const bgIdx, uint_t const priority) noex bg.priority = static_cast(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 { auto &s = ctx.spriteStates[idx]; s.enabled = false;