From 45fa6c87c2456382e40baeb5f69047f87cc99907 Mon Sep 17 00:00:00 2001 From: Lephe Date: Wed, 16 Nov 2022 18:10:22 +0100 Subject: [PATCH] render-cg: fix a bug with unaligned C_INVERT drect() The alignment optimization would write the edges twice, which is fine for opaque color fills, but cancels out for C_INVERT. --- src/render-cg/drect.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/render-cg/drect.c b/src/render-cg/drect.c index 248fe5c..6782fcb 100644 --- a/src/render-cg/drect.c +++ b/src/render-cg/drect.c @@ -33,8 +33,9 @@ void drect(int x1, int y1, int x2, int y2, int color) if(color == C_INVERT) for(int h = height; h; h--) { - base[x1] ^= 0xffff; - base[x2] ^= 0xffff; + /* We can't double-draw on base[x1] and base[x2] here */ + if(x1 & 1) base[x1] ^= 0xffff; + if(!(x2 & 1)) base[x2] ^= 0xffff; for(int w = 0; w < width; w++) v[w] ^= 0xffffffff; v += 198; base += 396;