summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2022-10-13 10:03:43 +0200
committerBad Diode <bd@badd10de.dev>2022-10-13 10:03:43 +0200
commita85aa571d9d998c41dd125c28b09b93c0004d51e (patch)
tree5c9e173559184435bec75c79a59f32fb7d3156b0
parentbff3fc6dc6a09e5e7acba24806567cc533f3cba0 (diff)
downloaduxnnst-a85aa571d9d998c41dd125c28b09b93c0004d51e.tar.gz
uxnnst-a85aa571d9d998c41dd125c28b09b93c0004d51e.zip
[WIP] Fix out of bounds screen drawing
-rw-r--r--src/ppu.c11
1 files 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) {
64 64
65void 65void
66ppu_pixel(u8 *layer, u16 x, u16 y, u8 color) { 66ppu_pixel(u8 *layer, u16 x, u16 y, u8 color) {
67 if(x < screen_width && y < screen_height) { 67 if (x >= screen_width || y >= screen_height) {
68 Uint32 i = x + y *screen_width; 68 return;
69 if(color != layer[i]) { 69 }
70 layer[i] = color; 70 Uint32 i = x + y *screen_width;
71 } 71 if(color != layer[i]) {
72 layer[i] = color;
72 } 73 }
73 dirty_lines[y] |= 1; 74 dirty_lines[y] |= 1;
74} 75}