From d4ab875bfe12bcfbbd919f86d1df81ab68021bb0 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 3 Jun 2022 00:38:43 -0700 Subject: [PATCH] DS Video: Update flags --- src/ds/renderers/software.c | 4 ++++ src/gba/renderers/software-private.h | 2 ++ src/gba/renderers/video-software.c | 19 +++++++++---------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/ds/renderers/software.c b/src/ds/renderers/software.c index 96b0d32af..ba09b7924 100644 --- a/src/ds/renderers/software.c +++ b/src/ds/renderers/software.c @@ -449,13 +449,16 @@ static void DSVideoSoftwareRendererDrawGBAScanline(struct GBAVideoRenderer* rend } } } else { + GBAVideoSoftwareRendererUpdateFlags(softwareRenderer, &softwareRenderer->bg[0]); GBAVideoSoftwareRendererDrawBackgroundMode0(softwareRenderer, &softwareRenderer->bg[0], y); } } if (TEST_LAYER_ENABLED(1)) { + GBAVideoSoftwareRendererUpdateFlags(softwareRenderer, &softwareRenderer->bg[1]); GBAVideoSoftwareRendererDrawBackgroundMode0(softwareRenderer, &softwareRenderer->bg[1], y); } if (TEST_LAYER_ENABLED(2)) { + GBAVideoSoftwareRendererUpdateFlags(softwareRenderer, &softwareRenderer->bg[2]); switch (GBARegisterDISPCNTGetMode(softwareRenderer->dispcnt)) { case 0: case 1: @@ -478,6 +481,7 @@ static void DSVideoSoftwareRendererDrawGBAScanline(struct GBAVideoRenderer* rend } } if (TEST_LAYER_ENABLED(3)) { + GBAVideoSoftwareRendererUpdateFlags(softwareRenderer, &softwareRenderer->bg[3]); switch (GBARegisterDISPCNTGetMode(softwareRenderer->dispcnt)) { case 0: GBAVideoSoftwareRendererDrawBackgroundMode0(softwareRenderer, &softwareRenderer->bg[3], y); diff --git a/src/gba/renderers/software-private.h b/src/gba/renderers/software-private.h index 14d737145..c0162374b 100644 --- a/src/gba/renderers/software-private.h +++ b/src/gba/renderers/software-private.h @@ -35,6 +35,8 @@ void GBAVideoSoftwareRendererPreprocessBuffer(struct GBAVideoSoftwareRenderer* r void GBAVideoSoftwareRendererPostprocessBuffer(struct GBAVideoSoftwareRenderer* renderer); int GBAVideoSoftwareRendererPreprocessSpriteLayer(struct GBAVideoSoftwareRenderer* renderer, int y); +void GBAVideoSoftwareRendererUpdateFlags(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* bg); + static inline unsigned _brighten(unsigned color, int y); static inline unsigned _darken(unsigned color, int y); diff --git a/src/gba/renderers/video-software.c b/src/gba/renderers/video-software.c index b7d8c1712..69ee9d56d 100644 --- a/src/gba/renderers/video-software.c +++ b/src/gba/renderers/video-software.c @@ -36,7 +36,6 @@ static void GBAVideoSoftwareRendererWriteBGY_HI(struct GBAVideoSoftwareBackgroun static void GBAVideoSoftwareRendererWriteBLDCNT(struct GBAVideoSoftwareRenderer* renderer, uint16_t value); static void _updatePalettes(struct GBAVideoSoftwareRenderer* renderer); -static void _updateFlags(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* bg); static void _breakWindow(struct GBAVideoSoftwareRenderer* softwareRenderer, struct WindowN* win, int y); static void _breakWindowInner(struct GBAVideoSoftwareRenderer* softwareRenderer, struct WindowN* win); @@ -615,33 +614,33 @@ static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* render switch (GBARegisterDISPCNTGetMode(softwareRenderer->dispcnt)) { case 0: if (softwareRenderer->bg[0].enabled == ENABLED_MAX) { - _updateFlags(softwareRenderer, &softwareRenderer->bg[0]); + GBAVideoSoftwareRendererUpdateFlags(softwareRenderer, &softwareRenderer->bg[0]); } if (softwareRenderer->bg[1].enabled == ENABLED_MAX) { - _updateFlags(softwareRenderer, &softwareRenderer->bg[1]); + GBAVideoSoftwareRendererUpdateFlags(softwareRenderer, &softwareRenderer->bg[1]); } // Fall through case 2: if (softwareRenderer->bg[3].enabled == ENABLED_MAX) { - _updateFlags(softwareRenderer, &softwareRenderer->bg[3]); + GBAVideoSoftwareRendererUpdateFlags(softwareRenderer, &softwareRenderer->bg[3]); } // Fall through case 3: case 4: case 5: if (softwareRenderer->bg[2].enabled == ENABLED_MAX) { - _updateFlags(softwareRenderer, &softwareRenderer->bg[2]); + GBAVideoSoftwareRendererUpdateFlags(softwareRenderer, &softwareRenderer->bg[2]); } break; case 1: if (softwareRenderer->bg[0].enabled == ENABLED_MAX) { - _updateFlags(softwareRenderer, &softwareRenderer->bg[0]); + GBAVideoSoftwareRendererUpdateFlags(softwareRenderer, &softwareRenderer->bg[0]); } if (softwareRenderer->bg[1].enabled == ENABLED_MAX) { - _updateFlags(softwareRenderer, &softwareRenderer->bg[1]); + GBAVideoSoftwareRendererUpdateFlags(softwareRenderer, &softwareRenderer->bg[1]); } if (softwareRenderer->bg[2].enabled == ENABLED_MAX) { - _updateFlags(softwareRenderer, &softwareRenderer->bg[2]); + GBAVideoSoftwareRendererUpdateFlags(softwareRenderer, &softwareRenderer->bg[2]); } break; } @@ -832,7 +831,7 @@ static void GBAVideoSoftwareRendererWriteBGCNT(struct GBAVideoSoftwareRenderer* bg->control = value; bg->yCache = -1; - _updateFlags(renderer, bg); + GBAVideoSoftwareRendererUpdateFlags(renderer, bg); } static void GBAVideoSoftwareRendererWriteBGX_LO(struct GBAVideoSoftwareBackground* bg, uint16_t value) { @@ -1083,7 +1082,7 @@ static void _updatePalettes(struct GBAVideoSoftwareRenderer* renderer) { } } -void _updateFlags(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* background) { +void GBAVideoSoftwareRendererUpdateFlags(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* background) { uint32_t flags = (background->priority << OFFSET_PRIORITY) | (background->index << OFFSET_INDEX) | FLAG_IS_BACKGROUND; if (background->target2) { flags |= FLAG_TARGET_2;