commit ee7a69c

neauoire  ·  2023-11-13 00:53:55 +0000 UTC
parent 0536b82
(Screen) Cached row only written when visible
1 files changed,  +9, -9
+9, -9
 1@@ -49,28 +49,28 @@ screen_fill(Uint8 *layer, int color)
 2 void
 3 screen_rect(Uint8 *layer, Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2, int color)
 4 {
 5-	int x, y, w, h;
 6+	int row, x, y, w, h;
 7 	if(!x1 && !y1) {
 8 		screen_fill(layer, color);
 9 		return;
10 	}
11 	w = uxn_screen.width, h = uxn_screen.height;
12 	for(y = y1; y < y2 && y < h; y++)
13-		for(x = x1; x < x2 && x < w; x++)
14-			layer[x + y * w] = color;
15+		for(x = x1, row = y * w; x < x2 && x < w; x++)
16+			layer[x + row] = color;
17 }
18 
19 static void
20 screen_2bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16 color, int fx, int fy)
21 {
22-	int w = uxn_screen.width, h = uxn_screen.height, opaque = (color % 5);
23+	int row, w = uxn_screen.width, h = uxn_screen.height, opaque = (color % 5);
24 	Uint8 *ch1 = &ram[addr], *ch2 = ch1 + 8;
25 	Uint16 y, ymod = (fy < 0 ? 7 : 0), ymax = y1 + ymod + fy * 8;
26 	Uint16 x, xmod = (fx > 0 ? 7 : 0), xmax = x1 + xmod - fx * 8;
27 	for(y = y1 + ymod; y != ymax; y += fy) {
28-		int row = y * w, c = *ch1++ | (*ch2++ << 8);
29+		int c = *ch1++ | (*ch2++ << 8);
30 		if(y < h)
31-			for(x = x1 + xmod; x != xmax; x -= fx, c >>= 1) {
32+			for(x = x1 + xmod, row = y * w; x != xmax; x -= fx, c >>= 1) {
33 				Uint8 ch = (c & 1) | ((c >> 7) & 2);
34 				if((opaque || ch) && x < w)
35 					layer[x + row] = blending[ch][color];
36@@ -81,14 +81,14 @@ screen_2bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16
37 static void
38 screen_1bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16 color, int fx, int fy)
39 {
40-	int w = uxn_screen.width, h = uxn_screen.height, opaque = (color % 5);
41+	int row, w = uxn_screen.width, h = uxn_screen.height, opaque = (color % 5);
42 	Uint8 *ch1 = &ram[addr];
43 	Uint16 y, ymod = (fy < 0 ? 7 : 0), ymax = y1 + ymod + fy * 8;
44 	Uint16 x, xmod = (fx > 0 ? 7 : 0), xmax = x1 + xmod - fx * 8;
45 	for(y = y1 + ymod; y != ymax; y += fy) {
46-		int row = y * w, c = *ch1++;
47+		int c = *ch1++;
48 		if(y < h)
49-			for(x = x1 + xmod; x != xmax; x -= fx, c >>= 1) {
50+			for(x = x1 + xmod, row = y * w; x != xmax; x -= fx, c >>= 1) {
51 				Uint8 ch = c & 1;
52 				if((opaque || ch) && x < w)
53 					layer[x + row] = blending[ch][color];