all repos — mgba @ 85c3ed4178e8c7e8a8b161255693562ecf4c10d9

mGBA Game Boy Advance Emulator

GBA Video: Fix sprite boundary conditions with mosaic
Jeffrey Pfau jeffrey@endrift.com
Wed, 31 Dec 2014 20:53:50 -0800
commit

85c3ed4178e8c7e8a8b161255693562ecf4c10d9

parent

bbfd7d8e2c3f46783edc8365f41c241194338b31

2 files changed, 11 insertions(+), 2 deletions(-)

jump to
M CHANGESCHANGES

@@ -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.csrc/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); \ }