From b327719e38c6fc626db490da00a6c45a55f11531 Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Sun, 1 Aug 2021 00:31:22 +0100 Subject: [PATCH] Reworked putpixel --- src/devices/ppu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/devices/ppu.c b/src/devices/ppu.c index 4024e90..b5a09f2 100644 --- a/src/devices/ppu.c +++ b/src/devices/ppu.c @@ -24,9 +24,9 @@ clear(Ppu *p) void putpixel(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 color) { - Uint8 mask = layer ? 0x3 : 0xc, shift = layer * 2; + Uint8 *pixel = &p->pixels[y * p->width + x], shift = layer * 2; if(x < p->width && y < p->height) - p->pixels[y * p->width + x] = (p->pixels[y * p->width + x] & mask) | (color << shift); + *pixel = (*pixel & ~(0x3 << shift)) | (color << shift); } void