From 8442e0b9cff74bf95c1e22e2da26f63b4793ab2d Mon Sep 17 00:00:00 2001 From: Lephe Date: Sat, 19 Nov 2022 23:41:47 +0100 Subject: [PATCH] render: fix missed clipping test in dtext() --- src/render-cg/topti.c | 3 ++- src/render-fx/topti.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/render-cg/topti.c b/src/render-cg/topti.c index eedb3b6..49ee6e4 100644 --- a/src/render-cg/topti.c +++ b/src/render-cg/topti.c @@ -59,7 +59,6 @@ static void topti_render(int x, int y, char const *str_char, font_t const *f, /* Vertical clipping */ if(x >= dwindow.right || y >= dwindow.bottom) return; if(y + height <= dwindow.top) return; - height = min(height, dwindow.bottom - y); int top_overflow = y - dwindow.top; if(top_overflow < 0) { @@ -67,6 +66,8 @@ static void topti_render(int x, int y, char const *str_char, font_t const *f, height += top_overflow; y -= top_overflow; } + height = min(height, dwindow.bottom - y); + if(height <= 0) return; /* Move to top row */ uint16_t *target = gint_vram + DWIDTH * y; diff --git a/src/render-fx/topti.c b/src/render-fx/topti.c index 6eb30a0..4dc3dd7 100644 --- a/src/render-fx/topti.c +++ b/src/render-fx/topti.c @@ -109,6 +109,7 @@ void topti_render(int x, int y, char const *str_char, font_t const *f, vdisp = dwindow.top - y; y = dwindow.top; } + if(vdisp >= height) return; uint32_t bg_mask[4]; masks(dwindow.left, dwindow.right, bg_mask);