all repos — mgba @ 9c40ebb301bcb95331205132b834b150d72f132c

mGBA Game Boy Advance Emulator

DS Video: Support sprites on the bottom of the screen
Vicki Pfau vi@endrift.com
Sun, 26 Feb 2017 13:31:19 -0800
commit

9c40ebb301bcb95331205132b834b150d72f132c

parent

164712fdd427032db2dc1839cc900853c40bee09

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

@@ -163,6 +163,8 @@

int start; int end; int masterEnd; + int masterHeight; + int masterScanlines; }; void GBAVideoSoftwareRendererCreate(struct GBAVideoSoftwareRenderer* renderer);
M src/ds/renderers/software.csrc/ds/renderers/software.c

@@ -94,10 +94,14 @@ struct DSVideoSoftwareRenderer* softwareRenderer = (struct DSVideoSoftwareRenderer*) renderer;

softwareRenderer->engA.d.palette = &renderer->palette[0]; softwareRenderer->engA.d.oam = &renderer->oam->oam[0]; softwareRenderer->engA.masterEnd = DS_VIDEO_HORIZONTAL_PIXELS; + softwareRenderer->engA.masterHeight = DS_VIDEO_VERTICAL_PIXELS; + softwareRenderer->engA.masterScanlines = DS_VIDEO_VERTICAL_TOTAL_PIXELS; softwareRenderer->engA.outputBufferStride = softwareRenderer->outputBufferStride; softwareRenderer->engB.d.palette = &renderer->palette[512]; softwareRenderer->engB.d.oam = &renderer->oam->oam[1]; softwareRenderer->engB.masterEnd = DS_VIDEO_HORIZONTAL_PIXELS; + softwareRenderer->engB.masterHeight = DS_VIDEO_VERTICAL_PIXELS; + softwareRenderer->engB.masterScanlines = DS_VIDEO_VERTICAL_TOTAL_PIXELS; softwareRenderer->engB.outputBufferStride = softwareRenderer->outputBufferStride; DSVideoSoftwareRendererReset(renderer);
M src/gba/renderers/video-software.csrc/gba/renderers/video-software.c

@@ -63,6 +63,8 @@ renderer->d.disableBG[3] = false;

renderer->d.disableOBJ = false; renderer->tileStride = 0x20; renderer->masterEnd = VIDEO_HORIZONTAL_PIXELS; + renderer->masterHeight = VIDEO_VERTICAL_PIXELS; + renderer->masterScanlines = VIDEO_VERTICAL_TOTAL_PIXELS; renderer->temporaryBuffer = 0; }

@@ -471,7 +473,7 @@ int height = GBAVideoObjSizes[GBAObjAttributesAGetShape(obj.a) * 4 + GBAObjAttributesBGetSize(obj.b)][1];

if (GBAObjAttributesAIsTransformed(obj.a)) { height <<= GBAObjAttributesAGetDoubleSize(obj.a); } - if (GBAObjAttributesAGetY(obj.a) < VIDEO_VERTICAL_PIXELS || GBAObjAttributesAGetY(obj.a) + height >= VIDEO_VERTICAL_TOTAL_PIXELS) { + if (GBAObjAttributesAGetY(obj.a) < renderer->masterHeight || GBAObjAttributesAGetY(obj.a) + height >= renderer->masterScanlines) { renderer->sprites[oamMax].y = GBAObjAttributesAGetY(obj.a); renderer->sprites[oamMax].endY = GBAObjAttributesAGetY(obj.a) + height; renderer->sprites[oamMax].obj = obj;

@@ -571,7 +573,7 @@ static void GBAVideoSoftwareRendererFinishFrame(struct GBAVideoRenderer* renderer) {

struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer; if (softwareRenderer->temporaryBuffer) { - mappedMemoryFree(softwareRenderer->temporaryBuffer, softwareRenderer->masterEnd * VIDEO_VERTICAL_PIXELS * 4); + mappedMemoryFree(softwareRenderer->temporaryBuffer, softwareRenderer->masterEnd * softwareRenderer->masterHeight * 4); softwareRenderer->temporaryBuffer = 0; } softwareRenderer->bg[2].sx = softwareRenderer->bg[2].refx;

@@ -591,7 +593,7 @@ struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;

const color_t* colorPixels = pixels; unsigned i; - for (i = 0; i < VIDEO_VERTICAL_PIXELS; ++i) { + for (i = 0; i < softwareRenderer->masterHeight; ++i) { memmove(&softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * i], &colorPixels[stride * i], softwareRenderer->masterEnd * BYTES_PER_PIXEL); } }