From 84bddfad69bb0760d2c5734ac6a74c17f56da87b Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 20 Jan 2020 18:09:26 -0800 Subject: [PATCH] GBA Video: Fix mosaic in modes 1-5 in OpenGL (fixes #1620) --- CHANGES | 1 + src/gba/renderers/gl.c | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 396c882a5..04108c128 100644 --- a/CHANGES +++ b/CHANGES @@ -102,6 +102,7 @@ Other fixes: - Core: Fix uninitialized memory issues with graphics caches - Core: Return null for out of bounds cached tile VRAM querying - GBA Video: Fix OpenGL fragment data binding + - GBA Video: Fix mosaic in modes 1-5 in OpenGL (fixes mgba.io/i/1620) - Debugger: Fix tracing skipping instructions (fixes mgba.io/i/1614) - OpenGL: Only invalidate texture if dimensions change (fixes mgba.io/i/1612) - Qt: Fix fast forward mute being reset (fixes mgba.io/i/1574) diff --git a/src/gba/renderers/gl.c b/src/gba/renderers/gl.c index 5b73f7c2c..3c433e81f 100644 --- a/src/gba/renderers/gl.c +++ b/src/gba/renderers/gl.c @@ -268,10 +268,10 @@ static const char* const _renderMode2 = " ivec2 offset[4];\n" " vec2 incoord = texCoord;\n" " if (mosaic.x > 1) {\n" - " incoord.x = float(int(incoord.x) % mosaic.x);\n" + " incoord.x = floor(incoord.x - float(int(incoord.x) % mosaic.x));\n" " }\n" " if (mosaic.y > 1) {\n" - " incoord.y = float(int(incoord.y) % mosaic.y);\n" + " incoord.y = floor(incoord.y - float(int(incoord.y) % mosaic.y));\n" " }\n" " loadAffine(int(incoord.y), mat, offset);\n" " float y = fract(incoord.y);\n" @@ -321,10 +321,10 @@ static const char* const _renderMode35 = " ivec2 offset[4];\n" " vec2 incoord = texCoord;\n" " if (mosaic.x > 1) {\n" - " incoord.x = float(int(incoord.x) % mosaic.x);\n" + " incoord.x = floor(incoord.x - float(int(incoord.x) % mosaic.x));\n" " }\n" " if (mosaic.y > 1) {\n" - " incoord.y = float(int(incoord.y) % mosaic.y);\n" + " incoord.y = floor(incoord.y - float(int(incoord.y) % mosaic.y));\n" " }\n" " loadAffine(int(incoord.y), mat, offset);\n" " float y = fract(incoord.y);\n" @@ -386,10 +386,10 @@ static const char* const _renderMode4 = " ivec2 offset[4];\n" " vec2 incoord = texCoord;\n" " if (mosaic.x > 1) {\n" - " incoord.x = float(int(incoord.x) % mosaic.x);\n" + " incoord.x = floor(incoord.x - float(int(incoord.x) % mosaic.x));\n" " }\n" " if (mosaic.y > 1) {\n" - " incoord.y = float(int(incoord.y) % mosaic.y);\n" + " incoord.y = floor(incoord.y - float(int(incoord.y) % mosaic.y));\n" " }\n" " loadAffine(int(incoord.y), mat, offset);\n" " float y = fract(incoord.y);\n"