Squashed 'deps/nostalgia/' changes from c7bc2a95..e27eee50

e27eee50 [teagba] Add set and scroll background offset functions
fd610454 [nostalgia/gfx] Fix compiler warning
e61d4647 [nostalgia/gfx] Fix BG tilesheet loading, add background offset functions
c275c5f5 [hull] Disable building hull for now
fbf49ba5 [ox/std] Add pre- and post-increment operators to Span
92f74b27 [ox/std] Add null check for deallocating in consteval context Vector
934f0c92 [ox/std] Add beginsWith and endsWith variants that that cingle chars
ee9a3e11 [ox/std] Cleanup
16886cdf [hull] Add start on command interpreter
08b9508d [ox/std] Give std::ignore a named type
69bd968f [nostalgia/player] Fix build
4e7dc666 [nostalgia,olympic] Rename string len() functions to size()
bea0cf5a [ox/std] Rename string len() functions to size()

git-subtree-dir: deps/nostalgia
git-subtree-split: e27eee50f05bb437710313430e0d9cef636a66b1
This commit is contained in:
2025-07-30 00:40:03 -05:00
parent 8a74e044dc
commit 1bfb7f99c2
47 changed files with 340 additions and 142 deletions

View File

@@ -54,25 +54,41 @@ inline volatile BgCtl &regBgCtl(uintptr_t const bgIdx) noexcept {
}
// background horizontal scrolling registers
#define REG_BG0HOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'0010))
#define REG_BG1HOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'0014))
#define REG_BG2HOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'0018))
#define REG_BG3HOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'001c))
#define REG_BG0HOFS (*reinterpret_cast<volatile int16_t*>(0x0400'0010))
#define REG_BG1HOFS (*reinterpret_cast<volatile int16_t*>(0x0400'0014))
#define REG_BG2HOFS (*reinterpret_cast<volatile int16_t*>(0x0400'0018))
#define REG_BG3HOFS (*reinterpret_cast<volatile int16_t*>(0x0400'001c))
[[nodiscard]]
volatile uint32_t &regBgHofs(auto const bgIdx) noexcept {
return *reinterpret_cast<volatile uint32_t*>(0x0400'0010 + 4 * bgIdx);
volatile int16_t &regBgHofs(auto const bgIdx) noexcept {
return *reinterpret_cast<volatile int16_t*>(0x0400'0010 + 4 * bgIdx);
}
// background vertical scrolling registers
#define REG_BG0VOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'0012))
#define REG_BG1VOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'0016))
#define REG_BG2VOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'001a))
#define REG_BG3VOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'001e))
#define REG_BG0VOFS (*reinterpret_cast<volatile int16_t*>(0x0400'0012))
#define REG_BG1VOFS (*reinterpret_cast<volatile int16_t*>(0x0400'0016))
#define REG_BG2VOFS (*reinterpret_cast<volatile int16_t*>(0x0400'001a))
#define REG_BG3VOFS (*reinterpret_cast<volatile int16_t*>(0x0400'001e))
[[nodiscard]]
volatile uint32_t &regBgVofs(auto const bgIdx) noexcept {
return *reinterpret_cast<volatile uint32_t*>(0x0400'0012 + 4 * bgIdx);
volatile int16_t &regBgVofs(auto const bgIdx) noexcept {
return *reinterpret_cast<volatile int16_t*>(0x0400'0012 + 4 * bgIdx);
}
// background scrolling registers
struct OffsetPair {
int16_t x{}, y{};
};
#define REG_BG0OFS (*reinterpret_cast<volatile OffsetPair*>(0x0400'0010))
#define REG_BG1OFS (*reinterpret_cast<volatile OffsetPair*>(0x0400'0014))
#define REG_BG2OFS (*reinterpret_cast<volatile OffsetPair*>(0x0400'0018))
#define REG_BG3OFS (*reinterpret_cast<volatile OffsetPair*>(0x0400'001c))
[[nodiscard]]
volatile OffsetPair &regBgOfs(auto const bgIdx) noexcept {
return *reinterpret_cast<volatile OffsetPair*>(0x0400'0010 + sizeof(OffsetPair) * bgIdx);
}
/////////////////////////////////////////////////////////////////

View File

@@ -41,4 +41,8 @@ void addSpriteUpdate(GbaSpriteAttrUpdate const &upd) noexcept;
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;
}

View File

@@ -12,7 +12,7 @@ namespace teagba {
static ox::Array<GbaSpriteAttrUpdate, 128> g_spriteBuffer;
GbaSpriteAttrUpdate &spriteAttr(size_t i) noexcept {
GbaSpriteAttrUpdate &spriteAttr(size_t const i) noexcept {
return g_spriteBuffer[i];
}
@@ -29,4 +29,16 @@ void applySpriteUpdates() noexcept {
}
}
void setBgOffset(uint16_t const bg, int16_t const x, int16_t const y) noexcept {
auto &o = regBgOfs(bg);
o.x = x;
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;
}
}