all repos — mgba @ 14e8b1230794f9b0018e990e2802954502a928e1

mGBA Game Boy Advance Emulator

DS Video: Basic preparatory work for porting scanline caching
Vicki Pfau vi@endrift.com
Tue, 21 Jul 2020 00:03:24 -0700
commit

14e8b1230794f9b0018e990e2802954502a928e1

parent

3ccffdc29eab88906a6cbb9d686f474261da4e16

2 files changed, 19 insertions(+), 0 deletions(-)

jump to
M include/mgba/internal/gba/renderers/video-software.hinclude/mgba/internal/gba/renderers/video-software.h

@@ -15,6 +15,9 @@ #include <mgba/gba/interface.h>

#include <mgba/internal/gba/io.h> #include <mgba/internal/gba/renderers/common.h> #include <mgba/internal/gba/video.h> +#ifdef M_CORE_DS +#include <mgba/internal/ds/video.h> +#endif struct GBAVideoSoftwareBackground { unsigned index;

@@ -158,7 +161,11 @@ uint16_t nextIo[REG_SOUND1CNT_LO >> 1];

struct ScanlineCache { uint16_t io[REG_SOUND1CNT_LO >> 1]; int32_t scale[2][2]; +#ifdef M_CORE_DS + } cache[DS_VIDEO_VERTICAL_PIXELS]; +#else } cache[GBA_VIDEO_VERTICAL_PIXELS]; +#endif int nextY; int start;
M src/ds/renderers/software.csrc/ds/renderers/software.c

@@ -378,6 +378,18 @@

static void DSVideoSoftwareRendererDrawGBAScanline(struct GBAVideoRenderer* renderer, struct DSGX* gx, int y) { struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer; + if (y == DS_VIDEO_VERTICAL_PIXELS - 1) { + softwareRenderer->nextY = 0; + } else { + softwareRenderer->nextY = y + 1; + } + + bool dirty = softwareRenderer->scanlineDirty[y >> 5] & (1 << (y & 0x1F)); + if (memcmp(softwareRenderer->nextIo, softwareRenderer->cache[y].io, sizeof(softwareRenderer->nextIo))) { + memcpy(softwareRenderer->cache[y].io, softwareRenderer->nextIo, sizeof(softwareRenderer->nextIo)); + dirty = true; + } + int x; color_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y]; if (GBARegisterDISPCNTIsForcedBlank(softwareRenderer->dispcnt)) {