DS GX: Simplify loop
Vicki Pfau vi@endrift.com
Thu, 02 Mar 2017 02:14:08 -0800
1 files changed,
14 insertions(+),
22 deletions(-)
jump to
M
src/ds/gx/software.c
→
src/ds/gx/software.c
@@ -426,31 +426,23 @@ }
span = DSGXSoftwareSpanListGetPointer(&softwareRenderer->activeSpans, nextSpanId - 1); nextSpanX = span->ep[0].x >> 12; } - if (i < nextSpanX) { - span = NULL; - } else { - struct DSGXSoftwareSpan* testSpan = DSGXSoftwareSpanListGetPointer(&softwareRenderer->activeSpans, nextSpanId - 1); - while (i > (testSpan->ep[0].x >> 12)) { - if (i <= (testSpan->ep[1].x >> 12)) { - _lerpEndpoint(testSpan, &ep, i); - color_t color = _lookupColor(&ep, testSpan->poly); - if (scanline[i] == FLAG_UNWRITTEN) { - scanline[i] = color; - } - if (ep.w >= depth) { - depth = ep.w; - span = testSpan; - if (color != FLAG_UNWRITTEN) { - scanline[i] = color; - } - } + while (i > (span->ep[0].x >> 12)) { + if (i <= (span->ep[1].x >> 12)) { + _lerpEndpoint(span, &ep, i); + color_t color = _lookupColor(&ep, span->poly); + if (scanline[i] == FLAG_UNWRITTEN) { + scanline[i] = color; } - --nextSpanId; - if (!nextSpanId) { - break; + if (ep.w >= depth && color != FLAG_UNWRITTEN) { + depth = ep.w; + scanline[i] = color; } - testSpan = DSGXSoftwareSpanListGetPointer(&softwareRenderer->activeSpans, nextSpanId - 1); + } + --nextSpanId; + if (!nextSpanId) { + break; } + span = DSGXSoftwareSpanListGetPointer(&softwareRenderer->activeSpans, nextSpanId - 1); } } }