Browse code

(screen) Housekeeping

Devine Lu Linvega authored on 05/05/2023 03:17:38
Showing 2 changed files
... ...
@@ -25,7 +25,7 @@ static Uint8 blending[4][16] = {
25 25
 	{2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}};
26 26
 
27 27
 static void
28
-screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2)
28
+screen_change(int x1, int y1, int x2, int y2)
29 29
 {
30 30
 	if(x1 < uxn_screen.x1) uxn_screen.x1 = x1;
31 31
 	if(y1 < uxn_screen.y1) uxn_screen.y1 = y1;
... ...
@@ -34,7 +34,7 @@ screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2)
34 34
 }
35 35
 
36 36
 static void
37
-screen_fill(Uint8 *pixels, Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2, Uint8 color)
37
+screen_fill(Uint8 *pixels, int x1, int y1, int x2, int y2, int color)
38 38
 {
39 39
 	int x, y, width = uxn_screen.width, height = uxn_screen.height;
40 40
 	for(y = y1; y < y2 && y < height; y++)
... ...
@@ -43,7 +43,7 @@ screen_fill(Uint8 *pixels, Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2, Uint8 col
43 43
 }
44 44
 
45 45
 static void
46
-screen_blit(Uint8 *pixels, Uint16 x1, Uint16 y1, Uint8 *ram, Uint16 addr, Uint8 color, Uint8 flipx, Uint8 flipy, Uint8 twobpp)
46
+screen_blit(Uint8 *pixels, Uint8 *ram, Uint16 addr, int x1, int y1, int color, int flipx, int flipy, int twobpp)
47 47
 {
48 48
 	int v, h, width = uxn_screen.width, height = uxn_screen.height, opaque = (color % 5) || !color;
49 49
 	for(v = 0; v < 8; v++) {
... ...
@@ -99,12 +99,13 @@ screen_resize(Uint16 width, Uint16 height)
99 99
 void
100 100
 screen_redraw(void)
101 101
 {
102
-	Uint32 i, x, y, w = uxn_screen.width, palette[16], *pixels = uxn_screen.pixels;
103 102
 	Uint8 *fg = uxn_screen.fg, *bg = uxn_screen.bg;
103
+	Uint32 palette[16], *pixels = uxn_screen.pixels;
104
+	int i, x, y, w = uxn_screen.width, h = uxn_screen.height;
104 105
 	int x1 = uxn_screen.x1;
105 106
 	int y1 = uxn_screen.y1;
106
-	int x2 = uxn_screen.x2 > uxn_screen.width ? uxn_screen.width : uxn_screen.x2;
107
-	int y2 = uxn_screen.y2 > uxn_screen.height ? uxn_screen.height : uxn_screen.y2;
107
+	int x2 = uxn_screen.x2 > w ? w : uxn_screen.x2;
108
+	int y2 = uxn_screen.y2 > h ? h : uxn_screen.y2;
108 109
 	for(i = 0; i < 16; i++)
109 110
 		palette[i] = uxn_screen.palette[(i >> 2) ? (i >> 2) : (i & 3)];
110 111
 	for(y = y1; y < y2; y++)
... ...
@@ -178,7 +179,7 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
178 179
 		Uint16 dy = (move & 0x2) << 2;
179 180
 		Uint8 *layer = (ctrl & 0x40) ? uxn_screen.fg : uxn_screen.bg;
180 181
 		for(i = 0; i <= length; i++) {
181
-			screen_blit(layer, x + dy * i, y + dx * i, ram, addr, ctrl & 0xf, ctrl & 0x10, ctrl & 0x20, twobpp);
182
+			screen_blit(layer, ram, addr, x + dy * i, y + dx * i, ctrl & 0xf, ctrl & 0x10, ctrl & 0x20, twobpp);
182 183
 			addr += (move & 0x04) << (1 + twobpp);
183 184
 		}
184 185
 		screen_change(x, y, x + dy * length + 8, y + dx * length + 8);
... ...
@@ -11,8 +11,7 @@ WITH REGARD TO THIS SOFTWARE.
11 11
 */
12 12
 
13 13
 typedef struct UxnScreen {
14
-	Uint32 palette[4], *pixels;
15
-	Uint16 width, height, x1, y1, x2, y2;
14
+	Uint32 palette[4], *pixels, width, height, x1, y1, x2, y2;
16 15
 	Uint8 *fg, *bg;
17 16
 } UxnScreen;
18 17