From 61ef3501c115bbaaced8f9c78685243ed4f31881 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 3 Mar 2017 19:08:27 -0800 Subject: [PATCH] DS Video: Minor extended background fixes --- include/mgba/internal/ds/video.h | 2 ++ src/ds/renderers/software.c | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/mgba/internal/ds/video.h b/include/mgba/internal/ds/video.h index e7c7afdae..14aa68dd6 100644 --- a/include/mgba/internal/ds/video.h +++ b/include/mgba/internal/ds/video.h @@ -64,6 +64,8 @@ DECL_BITFIELD(DSRegisterPOWCNT1, uint16_t); // TODO DECL_BIT(DSRegisterPOWCNT1, Swap, 15); +DECL_BIT(GBARegisterBGCNT, ExtendedMode0, 2); +DECL_BIT(GBARegisterBGCNT, ExtendedMode1, 7); DECL_BIT(GBARegisterBGCNT, ExtPaletteSlot, 13); DECL_BITFIELD(DSRegisterMASTER_BRIGHT, uint16_t); diff --git a/src/ds/renderers/software.c b/src/ds/renderers/software.c index 17ea5a082..78e08722c 100644 --- a/src/ds/renderers/software.c +++ b/src/ds/renderers/software.c @@ -414,7 +414,11 @@ static void DSVideoSoftwareRendererDrawGBAScanline(struct GBAVideoRenderer* rend GBAVideoSoftwareRendererDrawBackgroundMode2(softwareRenderer, &softwareRenderer->bg[2], y); break; case 5: - DSVideoSoftwareRendererDrawBackgroundExt0(softwareRenderer, &softwareRenderer->bg[2], y); + if (!GBARegisterBGCNTIsExtendedMode1(softwareRenderer->bg[2].control)) { + DSVideoSoftwareRendererDrawBackgroundExt0(softwareRenderer, &softwareRenderer->bg[2], y); + } else { + // TODO + } break; } } @@ -430,7 +434,11 @@ static void DSVideoSoftwareRendererDrawGBAScanline(struct GBAVideoRenderer* rend case 3: case 4: case 5: - DSVideoSoftwareRendererDrawBackgroundExt0(softwareRenderer, &softwareRenderer->bg[3], y); + if (!GBARegisterBGCNTIsExtendedMode1(softwareRenderer->bg[3].control)) { + DSVideoSoftwareRendererDrawBackgroundExt0(softwareRenderer, &softwareRenderer->bg[3], y); + } else { + // TODO + } break; } } @@ -659,7 +667,10 @@ void DSVideoSoftwareRendererDrawBackgroundExt0(struct GBAVideoSoftwareRenderer* color_t* mainPalette = background->extPalette; if (variant) { - palette = background->variantPalette; + mainPalette = background->variantPalette; + } + if (!mainPalette) { + return; } int paletteData;