all repos — mgba @ c9f0ac5c7b62bea8f83d3929d07132d0856ca4b8

mGBA Game Boy Advance Emulator

GBA Video: Fix postprocessing sprites with objwin and win0/1
Jeffrey Pfau jeffrey@endrift.com
Tue, 18 Nov 2014 03:03:18 -0800
commit

c9f0ac5c7b62bea8f83d3929d07132d0856ca4b8

parent

5b5c8c8d2d7b0bb76a770780aced880e212a7993

1 files changed, 9 insertions(+), 11 deletions(-)

jump to
M src/gba/renderers/video-software.csrc/gba/renderers/video-software.c

@@ -646,14 +646,14 @@ }

int priority; for (priority = 0; priority < 4; ++priority) { - if (spriteLayers & (1 << priority)) { - _postprocessSprite(renderer, priority); - } renderer->end = 0; for (w = 0; w < renderer->nWindows; ++w) { renderer->start = renderer->end; renderer->end = renderer->windows[w].endX; renderer->currentWindow = renderer->windows[w].control; + if (spriteLayers & (1 << priority)) { + _postprocessSprite(renderer, priority); + } if (TEST_LAYER_ENABLED(0) && GBARegisterDISPCNTGetMode(renderer->dispcnt) < 2) { _drawBackgroundMode0(renderer, &renderer->bg[0], y); }

@@ -1639,12 +1639,10 @@ bool objwinDisable = false;

bool objwinOnly = false; if (objwinSlowPath) { objwinDisable = !GBAWindowControlIsObjEnable(renderer->objwin.packed); - // TODO: Fix this for current window when WIN0/1 are enabled - objwinOnly = !objwinDisable && !GBAWindowControlIsObjEnable(renderer->winout.packed); - } - if (objwinSlowPath) { + objwinOnly = !objwinDisable && !GBAWindowControlIsObjEnable(renderer->currentWindow.packed); + if (objwinDisable) { - for (x = 0; x < VIDEO_HORIZONTAL_PIXELS; ++x, ++pixel) { + for (x = renderer->start; x < renderer->end; ++x, ++pixel) { uint32_t color = renderer->spriteLayer[x] & ~FLAG_OBJWIN; uint32_t current = *pixel; if ((color & FLAG_UNWRITTEN) != FLAG_UNWRITTEN && !(current & FLAG_OBJWIN) && (color & FLAG_PRIORITY) >> OFFSET_PRIORITY == priority) {

@@ -1653,7 +1651,7 @@ }

} return; } else if (objwinOnly) { - for (x = 0; x < VIDEO_HORIZONTAL_PIXELS; ++x, ++pixel) { + for (x = renderer->start; x < renderer->end; ++x, ++pixel) { uint32_t color = renderer->spriteLayer[x] & ~FLAG_OBJWIN; uint32_t current = *pixel; if ((color & FLAG_UNWRITTEN) != FLAG_UNWRITTEN && (current & FLAG_OBJWIN) && (color & FLAG_PRIORITY) >> OFFSET_PRIORITY == priority) {

@@ -1662,7 +1660,7 @@ }

} return; } else { - for (x = 0; x < VIDEO_HORIZONTAL_PIXELS; ++x, ++pixel) { + for (x = renderer->start; x < renderer->end; ++x, ++pixel) { uint32_t color = renderer->spriteLayer[x] & ~FLAG_OBJWIN; uint32_t current = *pixel; if ((color & FLAG_UNWRITTEN) != FLAG_UNWRITTEN && (color & FLAG_PRIORITY) >> OFFSET_PRIORITY == priority) {

@@ -1672,7 +1670,7 @@ }

return; } } - for (x = 0; x < VIDEO_HORIZONTAL_PIXELS; ++x, ++pixel) { + for (x = renderer->start; x < renderer->end; ++x, ++pixel) { uint32_t color = renderer->spriteLayer[x] & ~FLAG_OBJWIN; uint32_t current = *pixel; if ((color & FLAG_UNWRITTEN) != FLAG_UNWRITTEN && (color & FLAG_PRIORITY) >> OFFSET_PRIORITY == priority) {