GBA Video: Fix sprite boundary conditions with mosaic
Jeffrey Pfau jeffrey@endrift.com
Wed, 31 Dec 2014 20:53:50 -0800
2 files changed,
11 insertions(+),
2 deletions(-)
M
CHANGES
→
CHANGES
@@ -35,6 +35,7 @@ - Debugger: Align PC-relative loads in Thumb
- Debugger: Fix watchpoints triggering too late - GBA Video: Fix sprite mis-ordering behavior in some cases (fixes #168) - GBA Video: Fix window interactions with 16-color mode 0 mosaic + - GBA Video: Fix sprite boundary conditions with mosaic Misc: - Qt: Disable sync to video by default - GBA: Exit cleanly on FATAL if the port supports it
M
src/gba/renderers/video-software.c
→
src/gba/renderers/video-software.c
@@ -1578,14 +1578,22 @@ #define SPRITE_MOSAIC_LOOP(DEPTH, TYPE) \
SPRITE_YBASE_ ## DEPTH(inY); \ unsigned tileData; \ if (outX % mosaicH) { \ - inX += (mosaicH - (outX % mosaicH)) * xOffset; \ - outX += mosaicH - (outX % mosaicH); \ + if (!inX && xOffset > 0) { \ + inX = mosaicH - (outX % mosaicH); \ + outX += mosaicH - (outX % mosaicH); \ + } else if (inX == width - xOffset) { \ + inX = mosaicH + (outX % mosaicH); \ + outX += mosaicH - (outX % mosaicH); \ + } \ } \ for (; outX < condition; ++outX, inX += xOffset) { \ if (!(renderer->row[outX] & FLAG_UNWRITTEN)) { \ continue; \ } \ int localX = inX - xOffset * (outX % mosaicH); \ + if (localX < 0 || localX > width - 1) { \ + continue; \ + } \ SPRITE_XBASE_ ## DEPTH(localX); \ SPRITE_DRAW_PIXEL_ ## DEPTH ## _ ## TYPE(localX); \ }