summaryrefslogtreecommitdiff
path: root/arm9/source/main.c
diff options
context:
space:
mode:
authorBen Bridle <ben@derelict.engineering>2024-11-22 16:04:02 +1300
committerBen Bridle <ben@derelict.engineering>2024-11-22 16:15:11 +1300
commita05dc964313a3f1431b9d08d33afb4daf45c0819 (patch)
tree394074f98f30d7851a82038b1091456446df23c4 /arm9/source/main.c
parent4f8805869c469cb1b3685e03c3ea34d7654b5cb7 (diff)
downloadbedrock-nds-a05dc964313a3f1431b9d08d33afb4daf45c0819.zip
Update palette only when screen buffers flip
Previously, any palette updates would be immediately visible, but any screen updates would draw to the back buffer and would only become visible when the back buffer was copied to the front buffer. This could result in a flash of a new palette before the new screen had a chance to draw and become visible. To prevent this, a second palette was created to receive palette updates, with the updates only being copied to the visible palette when the screen buffers flip.
Diffstat (limited to 'arm9/source/main.c')
-rw-r--r--arm9/source/main.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/arm9/source/main.c b/arm9/source/main.c
index 8be7837..095e089 100644
--- a/arm9/source/main.c
+++ b/arm9/source/main.c
@@ -37,23 +37,6 @@ void receive_input(void) {
}
-Screen scr_main = {
- .bgv = BG_TILE_RAM(BG_SLOT_VIS),
- .fgv = BG_TILE_RAM(FG_SLOT_VIS),
- .bg = BG_TILE_RAM(BG_SLOT),
- .fg = BG_TILE_RAM(FG_SLOT),
- .map = BG_MAP_RAM(MAP_SLOT),
- .pal = BG_PALETTE,
-};
-Screen scr_sub = {
- .bgv = BG_TILE_RAM_SUB(BG_SLOT_VIS),
- .fgv = BG_TILE_RAM_SUB(FG_SLOT_VIS),
- .bg = BG_TILE_RAM_SUB(BG_SLOT),
- .fg = BG_TILE_RAM_SUB(FG_SLOT),
- .map = BG_MAP_RAM_SUB(MAP_SLOT),
- .pal = BG_PALETTE_SUB,
-};
-
int main(void) {
#define ALIVE(br) (br && br->alive)
#define AWAKE(br) (br && br->alive && br->awake)
@@ -79,8 +62,8 @@ int main(void) {
start_br(&br[1], keyboard_program, sizeof(keyboard_program));
br_main = &br[0];
br_sub = &br[1];
- br_main->scr.nds = &scr_main;
- br_sub->scr.nds = &scr_sub;
+ scr_make_main(&br_main->scr);
+ scr_make_sub(&br_sub->scr);
while (1) {
if (AWAKE(br_main)) run_br(br_main);