diff --git a/CHANGES b/CHANGES index d90047be2..fa64821a2 100644 --- a/CHANGES +++ b/CHANGES @@ -25,6 +25,7 @@ Emulation fixes: - 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) diff --git a/cinema/gba/obj/mosaic-height/baseline_0000.png b/cinema/gba/obj/mosaic-height/baseline_0000.png new file mode 100644 index 000000000..7f04ae705 Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0000.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0001.png b/cinema/gba/obj/mosaic-height/baseline_0001.png new file mode 100644 index 000000000..7f04ae705 Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0001.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0002.png b/cinema/gba/obj/mosaic-height/baseline_0002.png new file mode 100644 index 000000000..7f04ae705 Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0002.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0003.png b/cinema/gba/obj/mosaic-height/baseline_0003.png new file mode 100644 index 000000000..448ac5cee Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0003.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0004.png b/cinema/gba/obj/mosaic-height/baseline_0004.png new file mode 100644 index 000000000..448ac5cee Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0004.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0005.png b/cinema/gba/obj/mosaic-height/baseline_0005.png new file mode 100644 index 000000000..448ac5cee Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0005.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0006.png b/cinema/gba/obj/mosaic-height/baseline_0006.png new file mode 100644 index 000000000..448ac5cee Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0006.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0007.png b/cinema/gba/obj/mosaic-height/baseline_0007.png new file mode 100644 index 000000000..448ac5cee Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0007.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0008.png b/cinema/gba/obj/mosaic-height/baseline_0008.png new file mode 100644 index 000000000..448ac5cee Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0008.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0009.png b/cinema/gba/obj/mosaic-height/baseline_0009.png new file mode 100644 index 000000000..448ac5cee Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0009.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0010.png b/cinema/gba/obj/mosaic-height/baseline_0010.png new file mode 100644 index 000000000..448ac5cee Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0010.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0011.png b/cinema/gba/obj/mosaic-height/baseline_0011.png new file mode 100644 index 000000000..7f04ae705 Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0011.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0012.png b/cinema/gba/obj/mosaic-height/baseline_0012.png new file mode 100644 index 000000000..7f04ae705 Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0012.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0013.png b/cinema/gba/obj/mosaic-height/baseline_0013.png new file mode 100644 index 000000000..7f04ae705 Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0013.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0014.png b/cinema/gba/obj/mosaic-height/baseline_0014.png new file mode 100644 index 000000000..7f04ae705 Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0014.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0015.png b/cinema/gba/obj/mosaic-height/baseline_0015.png new file mode 100644 index 000000000..ac9d0e361 Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0015.png differ diff --git a/cinema/gba/obj/mosaic-height/baseline_0016.png b/cinema/gba/obj/mosaic-height/baseline_0016.png new file mode 100644 index 000000000..ac9d0e361 Binary files /dev/null and b/cinema/gba/obj/mosaic-height/baseline_0016.png differ diff --git a/cinema/gba/obj/mosaic-height/test.mvl b/cinema/gba/obj/mosaic-height/test.mvl new file mode 100644 index 000000000..3ab153bb2 Binary files /dev/null and b/cinema/gba/obj/mosaic-height/test.mvl differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0001.png b/cinema/gba/window/zmc-window-mosaic/baseline_0001.png index 53aee91ec..2e3825472 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0001.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0001.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0002.png b/cinema/gba/window/zmc-window-mosaic/baseline_0002.png index 237eab692..064470242 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0002.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0002.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0003.png b/cinema/gba/window/zmc-window-mosaic/baseline_0003.png index 05f308fa4..c5eb15ff1 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0003.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0003.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0004.png b/cinema/gba/window/zmc-window-mosaic/baseline_0004.png index 6c8b94d45..2fc7c052f 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0004.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0004.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0005.png b/cinema/gba/window/zmc-window-mosaic/baseline_0005.png index 044cf6ebe..906f6bfbe 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0005.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0005.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0006.png b/cinema/gba/window/zmc-window-mosaic/baseline_0006.png index 13ebb47bc..ce920fee6 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0006.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0006.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0007.png b/cinema/gba/window/zmc-window-mosaic/baseline_0007.png index b3835e1d1..ae9f61bc1 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0007.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0007.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0008.png b/cinema/gba/window/zmc-window-mosaic/baseline_0008.png index ef7b0b212..733106331 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0008.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0008.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0009.png b/cinema/gba/window/zmc-window-mosaic/baseline_0009.png index 35d54bf96..e2d9b1337 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0009.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0009.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0010.png b/cinema/gba/window/zmc-window-mosaic/baseline_0010.png index 8b555e49e..dd985ca72 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0010.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0010.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0011.png b/cinema/gba/window/zmc-window-mosaic/baseline_0011.png index cecd0ff34..fa1bd5e99 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0011.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0011.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0012.png b/cinema/gba/window/zmc-window-mosaic/baseline_0012.png index 4e4165d5e..af7e92a27 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0012.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0012.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0013.png b/cinema/gba/window/zmc-window-mosaic/baseline_0013.png index 3f8d3a57a..b76aeaf57 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0013.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0013.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0014.png b/cinema/gba/window/zmc-window-mosaic/baseline_0014.png index eb1e1c9fe..b7172d5dd 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0014.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0014.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0015.png b/cinema/gba/window/zmc-window-mosaic/baseline_0015.png index 3edbaea2b..5a68060cc 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0015.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0015.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0016.png b/cinema/gba/window/zmc-window-mosaic/baseline_0016.png index d3636525a..ea3fa2a16 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0016.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0016.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0017.png b/cinema/gba/window/zmc-window-mosaic/baseline_0017.png index 2d6086460..1d58c3978 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0017.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0017.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0018.png b/cinema/gba/window/zmc-window-mosaic/baseline_0018.png index c8cd44f8c..dc57ebf94 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0018.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0018.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0019.png b/cinema/gba/window/zmc-window-mosaic/baseline_0019.png index 2d9b989e9..1804399aa 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0019.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0019.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0020.png b/cinema/gba/window/zmc-window-mosaic/baseline_0020.png index 706120316..34b722b31 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0020.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0020.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0021.png b/cinema/gba/window/zmc-window-mosaic/baseline_0021.png index 792199be6..d47eb372f 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0021.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0021.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0022.png b/cinema/gba/window/zmc-window-mosaic/baseline_0022.png index 08a6d3dba..c9039b6ae 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0022.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0022.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0023.png b/cinema/gba/window/zmc-window-mosaic/baseline_0023.png index 57d99fa3c..382444fb8 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0023.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0023.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0024.png b/cinema/gba/window/zmc-window-mosaic/baseline_0024.png index a49291156..53d25bf03 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0024.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0024.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0025.png b/cinema/gba/window/zmc-window-mosaic/baseline_0025.png index 1dfa40cbe..bdc9c1218 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0025.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0025.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0026.png b/cinema/gba/window/zmc-window-mosaic/baseline_0026.png index ce427ed73..128561196 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0026.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0026.png differ diff --git a/cinema/gba/window/zmc-window-mosaic/baseline_0027.png b/cinema/gba/window/zmc-window-mosaic/baseline_0027.png index b9f6dc6f2..d6fcf6694 100644 Binary files a/cinema/gba/window/zmc-window-mosaic/baseline_0027.png and b/cinema/gba/window/zmc-window-mosaic/baseline_0027.png differ diff --git a/src/gba/renderers/software-obj.c b/src/gba/renderers/software-obj.c index e8a474c0a..a8a471e09 100644 --- a/src/gba/renderers/software-obj.c +++ b/src/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); \ diff --git a/src/gba/renderers/video-software.c b/src/gba/renderers/video-software.c index 0e5d7dd5f..4c83844ad 100644 --- a/src/gba/renderers/video-software.c +++ b/src/gba/renderers/video-software.c @@ -805,11 +805,17 @@ static void _drawScanline(struct GBAVideoSoftwareRenderer* renderer, int y) { 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) {