[teagba] Add set and scroll background offset functions
All checks were successful
Build / build (push) Successful in 1m15s
All checks were successful
Build / build (push) Successful in 1m15s
This commit is contained in:
40
deps/teagba/include/teagba/addresses.hpp
vendored
40
deps/teagba/include/teagba/addresses.hpp
vendored
@@ -54,25 +54,41 @@ inline volatile BgCtl ®BgCtl(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 ®BgHofs(auto const bgIdx) noexcept {
|
||||
return *reinterpret_cast<volatile uint32_t*>(0x0400'0010 + 4 * bgIdx);
|
||||
volatile int16_t ®BgHofs(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 ®BgVofs(auto const bgIdx) noexcept {
|
||||
return *reinterpret_cast<volatile uint32_t*>(0x0400'0012 + 4 * bgIdx);
|
||||
volatile int16_t ®BgVofs(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 ®BgOfs(auto const bgIdx) noexcept {
|
||||
return *reinterpret_cast<volatile OffsetPair*>(0x0400'0010 + sizeof(OffsetPair) * bgIdx);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
4
deps/teagba/include/teagba/gfx.hpp
vendored
4
deps/teagba/include/teagba/gfx.hpp
vendored
@@ -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;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user