From a85aa571d9d998c41dd125c28b09b93c0004d51e Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Thu, 13 Oct 2022 10:03:43 +0200 Subject: [WIP] Fix out of bounds screen drawing --- src/ppu.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ppu.c b/src/ppu.c index dcf4e9c..dde934e 100644 --- a/src/ppu.c +++ b/src/ppu.c @@ -64,11 +64,12 @@ rgb565(u32 rgba) { void ppu_pixel(u8 *layer, u16 x, u16 y, u8 color) { - if(x < screen_width && y < screen_height) { - Uint32 i = x + y *screen_width; - if(color != layer[i]) { - layer[i] = color; - } + if (x >= screen_width || y >= screen_height) { + return; + } + Uint32 i = x + y *screen_width; + if(color != layer[i]) { + layer[i] = color; } dirty_lines[y] |= 1; } -- cgit v1.2.1