[nostalgia/core] Add a background priority option
This commit is contained in:
parent
d0c90c39e0
commit
9840b6fdee
@ -52,6 +52,8 @@ void setBgStatus(Context &ctx, unsigned bg, bool status) noexcept;
|
|||||||
|
|
||||||
void setBgCbb(Context &ctx, unsigned bgIdx, unsigned cbb) noexcept;
|
void setBgCbb(Context &ctx, unsigned bgIdx, unsigned cbb) noexcept;
|
||||||
|
|
||||||
|
void setBgPriority(Context &ctx, uint_t bgIdx, uint_t priority) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param section describes which section of the selected TileSheetSpace to use (e.g. MEM_PALLETE_BG[section])
|
* @param section describes which section of the selected TileSheetSpace to use (e.g. MEM_PALLETE_BG[section])
|
||||||
*/
|
*/
|
||||||
|
@ -97,15 +97,16 @@ void setBgStatus(Context&, unsigned bg, bool status) noexcept {
|
|||||||
REG_DISPCTL = REG_DISPCTL | ((REG_DISPCTL & ~mask) | mask);
|
REG_DISPCTL = REG_DISPCTL | ((REG_DISPCTL & ~mask) | mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
static 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];
|
||||||
teagba::bgSetBpp(&bgCtl, cbbData.bpp);
|
teagba::bgSetBpp(&bgCtl, cbbData.bpp);
|
||||||
teagba::bgSetCbb(&bgCtl, cbb);
|
teagba::bgSetCbb(&bgCtl, cbb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBgCbb(Context&, unsigned bgIdx, unsigned cbb) noexcept {
|
void setBgPriority(Context&, uint_t bgIdx, uint_t priority) noexcept {
|
||||||
setBgCbb(nullptr, bgIdx, cbb);
|
auto &bgCtl = regBgCtl(bgIdx);
|
||||||
|
bgCtl = (bgCtl & 0b1111'1111'1111'1100u) | (priority & 0b11);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ox::Error loadBgTileSheet(
|
static ox::Error loadBgTileSheet(
|
||||||
@ -215,24 +216,24 @@ void clearTileLayer(Context&, unsigned bgIdx) noexcept {
|
|||||||
[[maybe_unused]]
|
[[maybe_unused]]
|
||||||
void hideSprite(Context&, unsigned idx) noexcept {
|
void hideSprite(Context&, unsigned idx) noexcept {
|
||||||
//oxAssert(g_spriteUpdates < config::GbaSpriteBufferLen, "Sprite update buffer overflow");
|
//oxAssert(g_spriteUpdates < config::GbaSpriteBufferLen, "Sprite update buffer overflow");
|
||||||
teagba::GbaSpriteAttrUpdate oa;
|
teagba::addSpriteUpdate({
|
||||||
oa.attr0 = uint16_t{0b11 << 8};
|
.attr0 = uint16_t{0b11 << 8},
|
||||||
oa.idx = static_cast<uint16_t>(idx);
|
.idx = static_cast<uint16_t>(idx),
|
||||||
teagba::addSpriteUpdate(oa);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[[maybe_unused]]
|
[[maybe_unused]]
|
||||||
void showSprite(Context&, unsigned idx) noexcept {
|
void showSprite(Context&, unsigned idx) noexcept {
|
||||||
//oxAssert(g_spriteUpdates < config::GbaSpriteBufferLen, "Sprite update buffer overflow");
|
//oxAssert(g_spriteUpdates < config::GbaSpriteBufferLen, "Sprite update buffer overflow");
|
||||||
teagba::GbaSpriteAttrUpdate oa;
|
teagba::addSpriteUpdate({
|
||||||
oa.attr0 &= uint16_t{0b1111'1100'1111'1111};
|
.attr0 = 0,
|
||||||
oa.idx = static_cast<uint16_t>(idx);
|
.idx = static_cast<uint16_t>(idx),
|
||||||
teagba::addSpriteUpdate(oa);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSprite(Context&, uint_t idx, Sprite const&s) noexcept {
|
void setSprite(Context&, uint_t idx, Sprite const&s) noexcept {
|
||||||
//oxAssert(g_spriteUpdates < config::GbaSpriteBufferLen, "Sprite update buffer overflow");
|
//oxAssert(g_spriteUpdates < config::GbaSpriteBufferLen, "Sprite update buffer overflow");
|
||||||
teagba::GbaSpriteAttrUpdate const oa{
|
teagba::addSpriteUpdate({
|
||||||
.attr0 = static_cast<uint16_t>(
|
.attr0 = static_cast<uint16_t>(
|
||||||
(static_cast<uint16_t>(s.y & ox::onMask<uint8_t>(0b111'1111)))
|
(static_cast<uint16_t>(s.y & ox::onMask<uint8_t>(0b111'1111)))
|
||||||
| (static_cast<uint16_t>(1) << 10) // enable alpha
|
| (static_cast<uint16_t>(1) << 10) // enable alpha
|
||||||
@ -245,8 +246,7 @@ void setSprite(Context&, uint_t idx, Sprite const&s) noexcept {
|
|||||||
(static_cast<uint16_t>(s.tileIdx & ox::onMask<uint16_t>(8)))
|
(static_cast<uint16_t>(s.tileIdx & ox::onMask<uint16_t>(8)))
|
||||||
| (static_cast<uint16_t>(s.priority & 0b11) << 10)),
|
| (static_cast<uint16_t>(s.priority & 0b11) << 10)),
|
||||||
.idx = static_cast<uint16_t>(idx),
|
.idx = static_cast<uint16_t>(idx),
|
||||||
};
|
});
|
||||||
teagba::addSpriteUpdate(oa);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user