From 9ccdf5bc8973e1936ff6255f8f02af304aff9084 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 17 Feb 2024 09:26:13 +0100 Subject: Make drawing more efficient --- src/ahoy/gui.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ahoy/gui.c b/src/ahoy/gui.c index 918ddbc..1201700 100644 --- a/src/ahoy/gui.c +++ b/src/ahoy/gui.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -87,15 +88,14 @@ windrw(void) SDL_SetRenderDrawColor(rndr, 0, 0, 0, UINT8_MAX); SDL_RenderClear(rndr); + SDL_SetRenderDrawColor(rndr, 0, UINT8_MAX, 0, UINT8_MAX); for (size_t i = 0; i < lengthof(c8.screen); i++) { - for (size_t j = 64; j-- > 0;) { - bool set = (UINT64_C(1) << j) & c8.screen[i]; + uint64_t row = c8.screen[i]; + while (row) { + int j = stdc_first_trailing_one(row) - 1; r.x = cols[j] * qw.quot + qw.rem / 2; r.y = i * qh.quot + qh.rem / 2; - if (set) - SDL_SetRenderDrawColor(rndr, 0, UINT8_MAX, 0, UINT8_MAX); - else - SDL_SetRenderDrawColor(rndr, 0, 0, 0, UINT8_MAX); + row ^= 1ULL << j; SDL_RenderFillRect(rndr, &r); } } -- cgit v1.2.3