uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 5709511c7e062de76cebee04a9be2a069516c976
parent 3818720eb2a90b0fdf1aad4db9a93ccdadd1826a
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Tue, 28 Feb 2023 19:34:13 -0800

(screen.c) Do not shift a zero in 1bpp

Diffstat:
Msrc/devices/screen.c | 17+++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/devices/screen.c b/src/devices/screen.c @@ -28,12 +28,13 @@ static Uint32 palette_mono[] = { static void screen_write(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 color) { - if(x < p->width && y < p->height) { - Uint32 i = x + y * p->width; - if(color != layer->pixels[i]) { - layer->pixels[i] = color; - layer->changed = 1; - } + Uint32 i; + if(x > p->width || y > p->height) + return; + i = x + y * p->width; + if(color != layer->pixels[i]) { + layer->pixels[i] = color; + layer->changed = 1; } } @@ -42,7 +43,7 @@ screen_blit(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 { int v, h, opaque = (color % 5) || !color; for(v = 0; v < 8; v++) { - Uint16 c = sprite[v] | (twobpp ? sprite[v + 8] : 0) << 8; + Uint16 c = sprite[v] | (twobpp ? (sprite[v + 8] << 8) : 0); for(h = 7; h >= 0; --h, c >>= 1) { Uint8 ch = (c & 1) | ((c >> 7) & 2); if(opaque || ch) @@ -179,7 +180,7 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port) n = d[0x6] >> 4; dx = (d[0x6] & 0x01) << 3; dy = (d[0x6] & 0x02) << 2; - if(addr > 0x10000 - ((n + 1) << (3 + twobpp))) + if(addr > 0xfff0) return; for(i = 0; i <= n; i++) { screen_blit(&uxn_screen, layer, x + dy * i, y + dx * i, &ram[addr], d[0xf] & 0xf, d[0xf] & 0x10, d[0xf] & 0x20, twobpp);