all repos — mgba @ 3056655060b3be0eabd35742ea2b8e1cb18ccb09

mGBA Game Boy Advance Emulator

GBA Video: Fix sprite mosaic clamping (fixes #1008)
Vicki Pfau vi@endrift.com
Mon, 20 May 2019 17:28:08 -0700
commit

3056655060b3be0eabd35742ea2b8e1cb18ccb09

parent

bda0f67103dfb316b6da67c4172e52a9e42d9ec1

48 files changed, 14 insertions(+), 14 deletions(-)

jump to
M CHANGESCHANGES

@@ -25,6 +25,7 @@ - GB Timer: Fix timing adjustments when writing to TAC (fixes mgba.io/i/1340)

- GBA Memory: Fix writing to OBJ memory in modes 3 and 5 - GBA: Fix RTC on non-standard sized ROMs (fixes mgba.io/i/1400) - GBA Memory: Prevent writing to mirrored BG VRAM (fixes mgba.io/i/743) + - GBA Video: Fix sprite mosaic clamping (fixes mgba.io/i/1008) Other fixes: - Qt: More app metadata fixes - Qt: Fix load recent from archive (fixes mgba.io/i/1325)
M src/gba/renderers/software-obj.csrc/gba/renderers/software-obj.c

@@ -17,19 +17,12 @@

#define SPRITE_MOSAIC_LOOP(DEPTH, TYPE) \ SPRITE_YBASE_ ## DEPTH(inY); \ unsigned tileData; \ - if (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) { \ int localX = inX - xOffset * (outX % mosaicH); \ - if (localX < 0 || localX > width - 1) { \ - continue; \ + if (localX < 0) { \ + localX = 0; \ + } else if (localX > width - 1) {\ + localX = width - 1; \ } \ SPRITE_XBASE_ ## DEPTH(localX); \ SPRITE_DRAW_PIXEL_ ## DEPTH ## _ ## TYPE(localX); \
M src/gba/renderers/video-software.csrc/gba/renderers/video-software.c

@@ -805,11 +805,17 @@ for (i = 0; i < renderer->oamMax; ++i) {

struct GBAVideoRendererSprite* sprite = &renderer->sprites[i]; int localY = y; renderer->end = 0; + if ((y < sprite->y && (sprite->endY - 256 < 0 || y >= sprite->endY - 256)) || y >= sprite->endY) { + continue; + } if (GBAObjAttributesAIsMosaic(sprite->obj.a)) { localY = mosaicY; - } - if ((localY < sprite->y && (sprite->endY - 256 < 0 || localY >= sprite->endY - 256)) || localY >= sprite->endY) { - continue; + if (localY < sprite->y) { + localY = sprite->y; + } + if (localY >= sprite->endY) { + localY = sprite->endY - 1; + } } for (w = 0; w < renderer->nWindows; ++w) { if (renderer->spriteCyclesRemaining <= 0) {