all repos — mgba @ ce40b8a03824659d123cc95556113b6795c4eac8

mGBA Game Boy Advance Emulator

DS GX: Fix alpha blending
Vicki Pfau vi@endrift.com
Sat, 18 Mar 2017 23:13:43 -0700
commit

ce40b8a03824659d123cc95556113b6795c4eac8

parent

edc88dc91e59d3becfc92334a1512d1259cbc5e9

2 files changed, 7 insertions(+), 10 deletions(-)

jump to
M include/mgba/internal/ds/gx.hinclude/mgba/internal/ds/gx.h

@@ -52,6 +52,7 @@ DECL_BITS(DSGXPolygonAttrs, Lights, 0, 4);

DECL_BITS(DSGXPolygonAttrs, Mode, 4, 2); DECL_BIT(DSGXPolygonAttrs, FrontFace, 6); DECL_BIT(DSGXPolygonAttrs, BackFace, 7); +DECL_BIT(DSGXPolygonAttrs, UpdateDepth, 11); // TODO DECL_BITS(DSGXPolygonAttrs, Alpha, 16, 5);
M src/ds/gx/software.csrc/ds/gx/software.c

@@ -631,15 +631,11 @@ if (softwareRenderer->wSort) {

if (span->ep[0].w < softwareRenderer->depthBuffer[x]) { softwareRenderer->depthBuffer[x] = span->ep[0].w; scanline[x] = color; - } else if (b < 0x1F) { - scanline[x] = _mix32(b, current, 0x1F - b, color) | a << 27; } } else { if (span->ep[0].z < softwareRenderer->depthBuffer[x]) { softwareRenderer->depthBuffer[x] = span->ep[0].z; scanline[x] = color; - } else if (b < 0x1F) { - scanline[x] = _mix32(b, current, 0x1F - b, color) | a << 27; } } } else if (a) {

@@ -650,17 +646,17 @@ color |= ab << 27;

} if (softwareRenderer->wSort) { if (span->ep[0].w < softwareRenderer->depthBuffer[x]) { - softwareRenderer->depthBuffer[x] = span->ep[0].w; + if (DSGXPolygonAttrsIsUpdateDepth(span->poly->poly->polyParams)) { + softwareRenderer->depthBuffer[x] = span->ep[0].w; + } scanline[x] = color; - } else if (b < 0x1F) { - scanline[x] = _mix32(b, current, 0x1F - b, color) | ab << 27; } } else { if (span->ep[0].z < softwareRenderer->depthBuffer[x]) { - softwareRenderer->depthBuffer[x] = span->ep[0].z; + if (DSGXPolygonAttrsIsUpdateDepth(span->poly->poly->polyParams)) { + softwareRenderer->depthBuffer[x] = span->ep[0].z; + } scanline[x] = color; - } else if (b < 0x1F) { - scanline[x] = _mix32(b, current, 0x1F - b, color) | ab << 27; } } }