Browse code

(screen.c) Skip blit when color is 0

Devine Lu Linvega authored on 14/04/2023 17:19:57
Showing 1 changed files
... ...
@@ -34,9 +34,11 @@ screen_fill(UxnScreen *s, Uint8 *pixels, Uint16 x1, Uint16 y1, Uint16 x2, Uint16
34 34
 }
35 35
 
36 36
 static void
37
-screen_blit(UxnScreen *p, Uint8 *pixels, Uint16 x1, Uint16 y1, Uint8 *ram, Uint16 addr, Uint8 color, Uint8 flipx, Uint8 flipy, Uint8 twobpp)
37
+screen_blit(UxnScreen *s, Uint8 *pixels, Uint16 x1, Uint16 y1, Uint8 *ram, Uint16 addr, Uint8 color, Uint8 flipx, Uint8 flipy, Uint8 twobpp)
38 38
 {
39
-	int v, h, width = p->width, height = p->height, opaque = (color % 5) || !color;
39
+	int v, h, width = s->width, height = s->height, opaque = (color % 5) || !color;
40
+	if(!color)
41
+		return screen_fill(s, pixels, x1, y1, x1 + 8, y1 + 8, 0);
40 42
 	for(v = 0; v < 8; v++) {
41 43
 		Uint16 c = ram[(addr + v) & 0xffff] | (twobpp ? (ram[(addr + v + 8) & 0xffff] << 8) : 0);
42 44
 		Uint16 y = y1 + (flipy ? 7 - v : v);
... ...
@@ -161,13 +163,8 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
161 163
 		Uint16 dy = (move & 0x2) << 2;
162 164
 		Layer *layer = (ctrl & 0x40) ? &uxn_screen.fg : &uxn_screen.bg;
163 165
 		for(i = 0; i <= length; i++) {
164
-			if(!(ctrl & 0xf)) {
165
-				Uint16 ex = x + dy * i, ey = y + dx * i;
166
-				screen_fill(&uxn_screen, layer->pixels, ex, ey, ex + 8, ey + 8, 0);
167
-			} else {
168
-				screen_blit(&uxn_screen, layer->pixels, x + dy * i, y + dx * i, ram, addr, ctrl & 0xf, ctrl & 0x10, ctrl & 0x20, twobpp);
169
-				addr += (move & 0x04) << (1 + twobpp);
170
-			}
166
+			screen_blit(&uxn_screen, layer->pixels, x + dy * i, y + dx * i, ram, addr, ctrl & 0xf, ctrl & 0x10, ctrl & 0x20, twobpp);
167
+			addr += (move & 0x04) << (1 + twobpp);
171 168
 		}
172 169
 		layer->changed = 1;
173 170
 		if(move & 0x1) POKE2(d + 0x8, x + dx); /* auto x+8 */