all repos — mgba @ 6509c4fffac8c593aa4515ab29b36b1ef6b26e3e

mGBA Game Boy Advance Emulator

DS GX: Clear depth
Vicki Pfau vi@endrift.com
Mon, 17 Jul 2017 14:49:32 -0700
commit

6509c4fffac8c593aa4515ab29b36b1ef6b26e3e

parent

8322117aab2460df3a68caa04a11b7286f21bd2b

5 files changed, 12 insertions(+), 5 deletions(-)

jump to
M CHANGESCHANGES

@@ -1,6 +1,7 @@

medusa alpha 3 (Future) Features: - DS GX: Toon shading + - DS GX: Clear depth Bugfixes: - DS GX: Fix vertex texture transformation (fixes mgba.io/i/702) - DS GX: Automatically normalize winding culling calculations (fixes mgba.io/i/699)
M README.mdREADME.md

@@ -182,7 +182,6 @@ - Graphics:

- Edge marking/wireframe - Highlight shading - Fog - - Clear depth - Anti-aliasing - Alpha test - Position test
M include/mgba/internal/ds/gx/software.hinclude/mgba/internal/ds/gx/software.h

@@ -95,6 +95,7 @@ color_t* scanlineCache;

int sort; uint16_t clearStencil; color_t clearColor; + uint32_t clearDepth; bool flushPending; struct DSGXVertex* verts;
M src/ds/gx.csrc/ds/gx.c

@@ -1326,6 +1326,7 @@ gx->currentVertex.color = 0x7FFF;

gx->currentPoly.polyParams = 0x001F00C0; gx->nextPoly.polyParams = 0x001F00C0; gx->dmaSource = -1; + gx->renderer->reset(gx->renderer); } void DSGXAssociateRenderer(struct DSGX* gx, struct DSGXRenderer* renderer) {
M src/ds/gx/software.csrc/ds/gx/software.c

@@ -440,6 +440,7 @@ static void DSGXSoftwareRendererReset(struct DSGXRenderer* renderer) {

struct DSGXSoftwareRenderer* softwareRenderer = (struct DSGXSoftwareRenderer*) renderer; softwareRenderer->clearColor = 0; softwareRenderer->clearStencil = 0; + softwareRenderer->clearDepth = 0xFFFFFF; } static void DSGXSoftwareRendererDeinit(struct DSGXRenderer* renderer) {

@@ -738,12 +739,13 @@ }

color_t clearColor = softwareRenderer->clearColor; uint16_t clearStencil = softwareRenderer->clearStencil; + uint32_t clearDepth = softwareRenderer->clearDepth; for (i = 0; i < DS_VIDEO_VERTICAL_PIXELS * DS_VIDEO_HORIZONTAL_PIXELS ; i += 4) { - softwareRenderer->depthBuffer[i] = INT32_MAX; - softwareRenderer->depthBuffer[i + 1] = INT32_MAX; - softwareRenderer->depthBuffer[i + 2] = INT32_MAX; - softwareRenderer->depthBuffer[i + 3] = INT32_MAX; + softwareRenderer->depthBuffer[i] = clearDepth; + softwareRenderer->depthBuffer[i + 1] = clearDepth; + softwareRenderer->depthBuffer[i + 2] = clearDepth; + softwareRenderer->depthBuffer[i + 3] = clearDepth; softwareRenderer->scanlineCache[i] = clearColor; softwareRenderer->scanlineCache[i + 1] = clearColor; softwareRenderer->scanlineCache[i + 2] = clearColor;

@@ -815,6 +817,9 @@ case DS9_REG_CLEAR_COLOR_HI:

softwareRenderer->clearColor &= 0x00FFFFFF; softwareRenderer->clearColor |= (value & 0x001F) << 27; softwareRenderer->clearStencil = (value & 0x3F00) >> 8; + break; + case DS9_REG_CLEAR_DEPTH: + softwareRenderer->clearDepth = (value & 0x7FFF) * 0x200 + 0x1FF; break; } }