all repos — mgba @ 30268324e8876f2a982e559310d39532094e5bda

mGBA Game Boy Advance Emulator

DS GX: Only recalculate W coordinate if it changes
Vicki Pfau vi@endrift.com
Tue, 28 Jul 2020 03:30:48 -0700
commit

30268324e8876f2a982e559310d39532094e5bda

parent

206ba1129d402eca85d33f5d7c362458de4dced9

1 files changed, 4 insertions(+), 2 deletions(-)

jump to
M src/ds/gx/software.csrc/ds/gx/software.c

@@ -398,8 +398,10 @@ static void _stepEndpoint(struct DSGXSoftwareSpan* span) {

int32_t nextX = (span->ep[0].coord[0] & ~0xFFF) + 0x1000; span->ep[0].coord[0] = nextX; - span->ep[0].wRecip += span->step.stepW; - span->ep[0].coord[3] = (0x7FFFFFFFFFFFFFFF / span->ep[0].wRecip) + 1; + if (span->step.stepW) { + span->ep[0].wRecip += span->step.stepW; + span->ep[0].coord[3] = (0x7FFFFFFFFFFFFFFF / span->ep[0].wRecip) + 1; + } span->ep[0].stepZ += span->step.stepZ; span->ep[0].coord[2] = _divideBy(span->ep[0].stepZ, span->ep[0].coord[3]);