commit a9bf231
neauoire
·
2023-11-13 00:36:36 +0000 UTC
parent 1706cdb
Housekeeping
1 files changed,
+18,
-13
+18,
-13
1@@ -49,16 +49,21 @@ 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, width = uxn_screen.width, height = uxn_screen.height;
6- for(y = y1; y < y2 && y < height; y++)
7- for(x = x1; x < x2 && x < width; x++)
8- layer[x + y * width] = color;
9+ int x, y, w, h;
10+ if(!x1 && !y1) {
11+ screen_fill(layer, color);
12+ return;
13+ }
14+ w = uxn_screen.width, h = uxn_screen.height;
15+ for(y = y1; y < y2 && y < h; y++)
16+ for(x = x1; x < x2 && x < w; x++)
17+ layer[x + y * w] = color;
18 }
19
20 static void
21 screen_2bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16 color, int fx, int fy)
22 {
23- int width = uxn_screen.width, height = uxn_screen.height, opaque = (color % 5);
24+ int w = uxn_screen.width, h = uxn_screen.height, opaque = (color % 5);
25 Uint8 *ch1 = &ram[addr], *ch2 = ch1 + 8;
26 Uint16 y, ymod = (fy < 0 ? 7 : 0), ymax = y1 + ymod + fy * 8;
27 Uint16 x, xmod = (fx > 0 ? 7 : 0), xmax = x1 + xmod - fx * 8;
28@@ -66,8 +71,8 @@ screen_2bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16
29 Uint16 c = *ch1++ | (*ch2++ << 8);
30 for(x = x1 + xmod; x != xmax; x -= fx, c >>= 1) {
31 Uint8 ch = (c & 1) | ((c >> 7) & 2);
32- if((opaque || ch) && x < width && y < height)
33- layer[x + y * width] = blending[ch][color];
34+ if((opaque || ch) && x < w && y < h)
35+ layer[x + y * w] = blending[ch][color];
36 }
37 }
38 }
39@@ -75,7 +80,7 @@ screen_2bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16
40 static void
41 screen_1bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16 color, int fx, int fy)
42 {
43- int width = uxn_screen.width, height = uxn_screen.height, opaque = (color % 5);
44+ int w = uxn_screen.width, h = uxn_screen.height, opaque = (color % 5);
45 Uint8 *ch1 = &ram[addr];
46 Uint16 y, ymod = (fy < 0 ? 7 : 0), ymax = y1 + ymod + fy * 8;
47 Uint16 x, xmod = (fx > 0 ? 7 : 0), xmax = x1 + xmod - fx * 8;
48@@ -83,8 +88,8 @@ screen_1bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16
49 Uint16 c = *ch1++;
50 for(x = x1 + xmod; x != xmax; x -= fx, c >>= 1) {
51 Uint8 ch = c & 1;
52- if((opaque || ch) && x < width && y < height)
53- layer[x + y * width] = blending[ch][color];
54+ if((opaque || ch) && x < w && y < h)
55+ layer[x + y * w] = blending[ch][color];
56 }
57 }
58 }
59@@ -240,9 +245,9 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
60 }
61 /* pixel mode */
62 else {
63- Uint16 width = uxn_screen.width, height = uxn_screen.height;
64- if(x < width && y < height)
65- layer[x + y * width] = color;
66+ Uint16 w = uxn_screen.width, h = uxn_screen.height;
67+ if(x < w && y < h)
68+ layer[x + y * w] = color;
69 screen_change(x, y, x + 1, y + 1);
70 if(d[0x6] & 0x1) POKE2(port_x, x + 1);
71 if(d[0x6] & 0x2) POKE2(port_y, y + 1);