From 5fd2f0c43adc426efd366e61de3486518fb33eec Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 4 Mar 2017 22:28:03 -0800 Subject: [PATCH] DS Software: Extend master bright to VRAM mode --- include/mgba/internal/ds/renderers/software.h | 2 - src/ds/renderers/software.c | 82 +++++++++---------- src/ds/video.c | 2 +- 3 files changed, 41 insertions(+), 45 deletions(-) diff --git a/include/mgba/internal/ds/renderers/software.h b/include/mgba/internal/ds/renderers/software.h index 6b591dbac..7101822ee 100644 --- a/include/mgba/internal/ds/renderers/software.h +++ b/include/mgba/internal/ds/renderers/software.h @@ -26,8 +26,6 @@ struct DSVideoSoftwareRenderer { color_t* outputBuffer; int outputBufferStride; - uint32_t row[DS_VIDEO_HORIZONTAL_PIXELS]; - color_t extPaletteA[16384]; color_t extPaletteB[16384]; color_t variantPaletteA[16384]; diff --git a/src/ds/renderers/software.c b/src/ds/renderers/software.c index bcadfe642..3425710bd 100644 --- a/src/ds/renderers/software.c +++ b/src/ds/renderers/software.c @@ -452,33 +452,6 @@ static void DSVideoSoftwareRendererDrawGBAScanline(struct GBAVideoRenderer* rend softwareRenderer->bg[3].sy += softwareRenderer->bg[3].dmy; GBAVideoSoftwareRendererPostprocessBuffer(softwareRenderer); - -#ifdef COLOR_16_BIT -#if defined(__ARM_NEON) && !defined(__APPLE__) - _to16Bit(row, softwareRenderer->row, softwareRenderer->masterEnd); -#else - for (x = 0; x < softwareRenderer->masterEnd; ++x) { - row[x] = softwareRenderer->row[x]; - } -#endif -#else - switch (softwareRenderer->masterBright) { - case 0: - default: - memcpy(row, softwareRenderer->row, softwareRenderer->masterEnd * sizeof(*row)); - break; - case 1: - for (x = 0; x < softwareRenderer->masterEnd; ++x) { - row[x] = _brighten(softwareRenderer->row[x], softwareRenderer->masterBrightY); - } - break; - case 2: - for (x = 0; x < softwareRenderer->masterEnd; ++x) { - row[x] = _darken(softwareRenderer->row[x], softwareRenderer->masterBrightY); - } - break; - } -#endif } static void _drawScanlineA(struct DSVideoSoftwareRenderer* softwareRenderer, int y) { @@ -495,7 +468,7 @@ static void _drawScanlineA(struct DSVideoSoftwareRenderer* softwareRenderer, int return; case 1: DSVideoSoftwareRendererDrawGBAScanline(&softwareRenderer->engA.d, softwareRenderer->d.gx, y); - return; + break; case 2: { uint16_t* vram = &softwareRenderer->d.vram[0x10000 * DSRegisterDISPCNTGetVRAMBlock(softwareRenderer->dispcntA)]; for (x = 0; x < DS_VIDEO_HORIZONTAL_PIXELS; ++x) { @@ -515,7 +488,7 @@ static void _drawScanlineA(struct DSVideoSoftwareRenderer* softwareRenderer, int color16 |= (color & 0x7C00) >> 10; color = color16; #endif - softwareRenderer->row[x] = color; + softwareRenderer->engA.row[x] = color; } break; } @@ -525,14 +498,29 @@ static void _drawScanlineA(struct DSVideoSoftwareRenderer* softwareRenderer, int #ifdef COLOR_16_BIT #if defined(__ARM_NEON) && !defined(__APPLE__) - _to16Bit(row, softwareRenderer->row, DS_VIDEO_HORIZONTAL_PIXELS); + _to16Bit(row, softwareRenderer->engA.row, DS_VIDEO_HORIZONTAL_PIXELS); #else for (x = 0; x < DS_VIDEO_HORIZONTAL_PIXELS; ++x) { - row[x] = softwareRenderer->row[x]; + row[x] = softwareRenderer->engA.row[x]; } #endif #else - memcpy(row, softwareRenderer->row, DS_VIDEO_HORIZONTAL_PIXELS * sizeof(*row)); + switch (softwareRenderer->engA.masterBright) { + case 0: + default: + memcpy(row, softwareRenderer->engA.row, softwareRenderer->engA.masterEnd * sizeof(*row)); + break; + case 1: + for (x = 0; x < DS_VIDEO_HORIZONTAL_PIXELS; ++x) { + row[x] = _brighten(softwareRenderer->engA.row[x], softwareRenderer->engA.masterBrightY); + } + break; + case 2: + for (x = 0; x < DS_VIDEO_HORIZONTAL_PIXELS; ++x) { + row[x] = _darken(softwareRenderer->engA.row[x], softwareRenderer->engA.masterBrightY); + } + break; + } #endif } @@ -550,19 +538,34 @@ static void _drawScanlineB(struct DSVideoSoftwareRenderer* softwareRenderer, int return; case 1: DSVideoSoftwareRendererDrawGBAScanline(&softwareRenderer->engB.d, NULL, y); - return; + break; } #ifdef COLOR_16_BIT #if defined(__ARM_NEON) && !defined(__APPLE__) - _to16Bit(row, softwareRenderer->row, DS_VIDEO_HORIZONTAL_PIXELS); + _to16Bit(row, softwareRenderer->engB.row, DS_VIDEO_HORIZONTAL_PIXELS); #else for (x = 0; x < DS_VIDEO_HORIZONTAL_PIXELS; ++x) { - row[x] = softwareRenderer->row[x]; + row[x] = softwareRenderer->engB.row[x]; } #endif #else - memcpy(row, softwareRenderer->row, DS_VIDEO_HORIZONTAL_PIXELS * sizeof(*row)); + switch (softwareRenderer->engB.masterBright) { + case 0: + default: + memcpy(row, softwareRenderer->engB.row, softwareRenderer->engB.masterEnd * sizeof(*row)); + break; + case 1: + for (x = 0; x < DS_VIDEO_HORIZONTAL_PIXELS; ++x) { + row[x] = _brighten(softwareRenderer->engB.row[x], softwareRenderer->engB.masterBrightY); + } + break; + case 2: + for (x = 0; x < DS_VIDEO_HORIZONTAL_PIXELS; ++x) { + row[x] = _darken(softwareRenderer->engB.row[x], softwareRenderer->engB.masterBrightY); + } + break; + } #endif } @@ -582,13 +585,8 @@ static void DSVideoSoftwareRendererDrawScanline(struct DSVideoRenderer* renderer static void DSVideoSoftwareRendererDrawScanlineDirectly(struct DSVideoRenderer* renderer, int y, color_t* scanline) { struct DSVideoSoftwareRenderer* softwareRenderer = (struct DSVideoSoftwareRenderer*) renderer; - if (!DSRegisterPOWCNT1IsSwap(softwareRenderer->powcnt)) { - softwareRenderer->engA.outputBuffer = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * DS_VIDEO_VERTICAL_PIXELS]; - } else { - softwareRenderer->engA.outputBuffer = softwareRenderer->outputBuffer; - } - DSVideoSoftwareRendererDrawGBAScanline(&softwareRenderer->engA.d, softwareRenderer->d.gx, y); + memcpy(scanline, softwareRenderer->engA.row, softwareRenderer->engA.masterEnd * sizeof(*scanline)); } static void DSVideoSoftwareRendererFinishFrame(struct DSVideoRenderer* renderer) { diff --git a/src/ds/video.c b/src/ds/video.c index 2251810df..2c7c4bd82 100644 --- a/src/ds/video.c +++ b/src/ds/video.c @@ -223,7 +223,7 @@ static void _performCapture(struct DSVideo* video, int y) { } uint16_t* vram = &video->vram[0x10000 * block + DSRegisterDISPCAPCNTGetWriteOffset(dispcap) * 0x4000]; const color_t* pixelsA; - color_t pixels[DS_VIDEO_VERTICAL_PIXELS]; + color_t pixels[DS_VIDEO_HORIZONTAL_PIXELS]; int width = DS_VIDEO_HORIZONTAL_PIXELS; switch (DSRegisterDISPCAPCNTGetCaptureSize(dispcap)) { case 0: