commit d408b10

Devine Lu Linvega  ·  2025-12-30 22:06:50 +0000 UTC
parent 2f06280
Removed margin marcos
1 files changed,  +15, -15
+15, -15
 1@@ -402,8 +402,6 @@ console_close(void)
 2 /*
 3 @|Screen ------------------------------------------------------------ */
 4 
 5-#define MAR(x) (x + 0x8)
 6-#define MAR2(x) (x + 0x10)
 7 static int screen_zoom = 1;
 8 
 9 static Uint8 *screen_layers;
10@@ -464,8 +462,8 @@ screen_resize(int width, int height)
11 {
12 	if(width != screen_width || height != screen_height) {
13 		int length;
14-		screen_width = width, screen_wmar2 = MAR2(width);
15-		screen_height = height, screen_hmar2 = MAR2(height);
16+		screen_width = width, screen_wmar2 = width + 0x10;
17+		screen_height = height, screen_hmar2 = height + 0x10;
18 		length = screen_wmar2 * screen_hmar2;
19 		screen_layers = realloc(screen_layers, length);
20 		memset(screen_layers, 0, length);
21@@ -478,10 +476,10 @@ screen_redraw(void)
22 {
23 	int x, y;
24 	if(screen_zoom == 1) {
25-		int colmar = MAR(screen_y1) * screen_wmar2;
26+		int colmar = (screen_y1 + 8) * screen_wmar2;
27 		int *dst = &screen_pixels[screen_y1 * screen_width + screen_x1];
28 		for(y = screen_y1; y < screen_y2; y++, dst += screen_width, colmar += screen_wmar2) {
29-			int i = MAR(screen_x1) + colmar;
30+			int i = (screen_x1 + 8) + colmar;
31 			int *a = dst, *b = a + (screen_x2 - screen_x1);
32 			while(a < b)
33 				*a++ = screen_palette[screen_layers[i++]];
34@@ -490,7 +488,7 @@ screen_redraw(void)
35 		int i, k, l;
36 		for(y = screen_y1; y < screen_y2; y++) {
37 			const int ys = y * screen_zoom;
38-			for(x = screen_x1, i = MAR(x) + MAR(y) * screen_wmar2; x < screen_x2; x++, i++) {
39+			for(x = screen_x1, i = (x + 8) + (y + 8) * screen_wmar2; x < screen_x2; x++, i++) {
40 				const int c = screen_palette[screen_layers[i]];
41 				for(k = 0; k < screen_zoom; k++) {
42 					const int oo = (ys + k) * screen_width * screen_zoom + x * screen_zoom;
43@@ -531,7 +529,7 @@ screen_update(void)
44 static void
45 screen_draw_pixel(void)
46 {
47-	int layer_mask, color;
48+	int layer_mask, color, px;
49 	const int ctrl = dev[0x2e];
50 	const int len = screen_wmar2;
51 	if(ctrl & 0x40)
52@@ -540,7 +538,7 @@ screen_draw_pixel(void)
53 		layer_mask = 0xc, color = ctrl & 0x3;
54 	/* fill mode */
55 	if(ctrl & 0x80) {
56-		int x1, y1, x2, y2, ax, bx, ay, by, hor, ver;
57+		int x1, y1, x2, y2, ay, by;
58 		if(ctrl & 0x10)
59 			x1 = 0, x2 = rX;
60 		else
61@@ -550,15 +548,17 @@ screen_draw_pixel(void)
62 		else
63 			y1 = rY, y2 = screen_height;
64 		screen_reqdraw = 1;
65-		x1 = MAR(x1), y1 = MAR(y1);
66-		hor = MAR(x2) - x1, ver = MAR(y2) - y1;
67-		for(ay = y1 * len, by = ay + ver * len; ay < by; ay += len)
68-			for(ax = ay + x1, bx = ax + hor; ax < bx; ax++)
69-				screen_layers[ax] = (screen_layers[ax] & layer_mask) | color;
70+		x1 = x1 + 8, y1 = y1 + 8;
71+		const int hor = (x2 + 8) - x1, ver = (y2 + 8) - y1;
72+		for(ay = y1 * len, by = ay + ver * len; ay < by; ay += len) {
73+			Uint8 *dst = &screen_layers[ay + x1];
74+			for(px = 0; px < hor; px++)
75+				dst[px] = (dst[px] & layer_mask) | color;
76+		}
77 	}
78 	/* pixel mode */
79 	else {
80-		const unsigned int x = rX, y = rY;
81+		const int x = rX, y = rY;
82 		if(x < len && y < screen_height) {
83 			Uint8 *dst = &screen_layers[(x + 8) + (y + 8) * len];
84 			*dst = (*dst & layer_mask) | color;