[nostalgia/core/gba] Add hideSprite and add flipX parameter to setSrpite
This commit is contained in:
parent
4ad959cd74
commit
80f98802b6
@ -76,6 +76,8 @@ using interrupt_handler = void (*)(void);
|
||||
#define MEM_IWRAM_BEGIN reinterpret_cast<uint8_t*>(0x03000000)
|
||||
#define MEM_IWRAM_END reinterpret_cast<uint8_t*>(0x03007FFF)
|
||||
|
||||
#define REG_BLNDCTL *reinterpret_cast<uint16_t*>(0x04000050)
|
||||
|
||||
#define MEM_BG_PALETTE reinterpret_cast<uint16_t*>(0x05000000)
|
||||
#define MEM_SPRITE_PALETTE reinterpret_cast<uint16_t*>(0x05000200)
|
||||
|
||||
|
@ -214,12 +214,33 @@ void clearTileLayer(Context*, int layer) {
|
||||
memset(&MEM_BG_MAP[layer], 0, GbaTileRows * GbaTileColumns);
|
||||
}
|
||||
|
||||
void setSprite(unsigned idx, unsigned x, unsigned y, unsigned tileIdx, unsigned spriteShape, unsigned spriteSize) {
|
||||
void hideSprite(unsigned idx) {
|
||||
GbaSpriteAttrUpdate oa;
|
||||
oa.attr0 = 2 << 8;
|
||||
oa.idx = idx;
|
||||
// block until g_spriteUpdates is less than buffer len
|
||||
if (g_spriteUpdates >= config::GbaSpriteBufferLen) {
|
||||
nostalgia_core_vblankintrwait();
|
||||
}
|
||||
if constexpr(config::GbaEventLoopTimerBased) {
|
||||
REG_IE &= ~Int_vblank; // disable vblank interrupt handler
|
||||
g_spriteBuffer[g_spriteUpdates++] = oa;
|
||||
REG_IE |= Int_vblank; // enable vblank interrupt handler
|
||||
} else {
|
||||
auto ie = REG_IE; // disable vblank interrupt handler
|
||||
REG_IE &= ~Int_vblank; // disable vblank interrupt handler
|
||||
g_spriteBuffer[g_spriteUpdates++] = oa;
|
||||
REG_IE = ie; // enable vblank interrupt handler
|
||||
}
|
||||
}
|
||||
|
||||
void setSprite(unsigned idx, unsigned x, unsigned y, unsigned tileIdx, unsigned spriteShape, unsigned spriteSize, unsigned flipX) {
|
||||
GbaSpriteAttrUpdate oa;
|
||||
oa.attr0 = static_cast<uint16_t>(y & ox::onMask<uint8_t>(7))
|
||||
| (static_cast<uint16_t>(1) << 10) // enable alpha
|
||||
| (static_cast<uint16_t>(spriteShape) << 14);
|
||||
oa.attr1 = (static_cast<uint16_t>(x) & ox::onMask<uint8_t>(8))
|
||||
| (static_cast<uint16_t>(flipX) << 12)
|
||||
| (static_cast<uint16_t>(spriteSize) << 14);
|
||||
oa.attr2 = static_cast<uint16_t>(tileIdx & ox::onMask<uint16_t>(8));
|
||||
oa.idx = idx;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2019 gtalent2@gmail.com
|
||||
* Copyright 2016 - 2020 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -127,6 +127,6 @@ void setTile(Context *ctx, int layer, int column, int row, uint8_t tile);
|
||||
|
||||
void clearTileLayer(Context*, int layer);
|
||||
|
||||
void setSprite(unsigned idx, unsigned x, unsigned y, unsigned tileIdx, unsigned tileShape = 0, unsigned spriteSize = 0);
|
||||
void setSprite(unsigned idx, unsigned x, unsigned y, unsigned tileIdx, unsigned spriteShape = 0, unsigned spriteSize = 0, unsigned flipX = 0);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2019 gtalent2@gmail.com
|
||||
* Copyright 2016 - 2020 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -200,7 +200,10 @@ void setTile(Context *ctx, int layer, int column, int row, uint8_t tile) {
|
||||
id->bgTileMaps[z][y][x] = tile;
|
||||
}
|
||||
|
||||
void setSprite(unsigned, unsigned, unsigned, unsigned, unsigned, unsigned) {
|
||||
void hideSprite(unsigned) {
|
||||
}
|
||||
|
||||
void setSprite(unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned) {
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user