commit f181416

Devine Lu Linvega  ·  2023-05-05 03:37:06 +0000 UTC
parent 6785c30
Renamed zoom for scale
3 files changed,  +8, -8
+3, -3
 1@@ -75,7 +75,7 @@ screen_resize(UxnScreen *p, Uint16 width, Uint16 height)
 2 		return;
 3 	bg = realloc(p->bg.pixels, width * height),
 4 	fg = realloc(p->fg.pixels, width * height);
 5-	pixels = realloc(p->pixels, width * height * sizeof(Uint32) * ZOOM * ZOOM);
 6+	pixels = realloc(p->pixels, width * height * sizeof(Uint32) * SCALE * SCALE);
 7 	if(!bg || !fg || !pixels)
 8 		return;
 9 	p->bg.pixels = bg;
10@@ -91,12 +91,12 @@ void
11 screen_redraw(UxnScreen *p)
12 {
13 	Uint8 *fg = p->fg.pixels, *bg = p->bg.pixels;
14-	Uint32 i, j, x, y, w = p->width * ZOOM, h = p->height * ZOOM, palette[16], *pixels = p->pixels;
15+	Uint32 i, j, x, y, w = p->width * SCALE, h = p->height * SCALE, palette[16], *pixels = p->pixels;
16 	for(i = 0; i < 16; i++)
17 		palette[i] = p->palette[(i >> 2) ? (i >> 2) : (i & 3)];
18 	for(y = 0; y < h; y++)
19 		for(x = 0; x < w; x++) {
20-			j = ((x / ZOOM) + (y / ZOOM) * p->width);
21+			j = ((x / SCALE) + (y / SCALE) * p->width);
22 			pixels[x + y * w] = palette[fg[j] << 2 | bg[j]];
23 		}
24 	p->fg.changed = p->bg.changed = 0;
+1, -1
1@@ -10,7 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
2 WITH REGARD TO THIS SOFTWARE.
3 */
4 
5-#define ZOOM 2
6+#define SCALE 2
7 
8 typedef struct Layer {
9 	Uint8 *pixels, changed;
+4, -4
 1@@ -72,7 +72,7 @@ static void
 2 emu_draw(void)
 3 {
 4 	screen_redraw(&uxn_screen);
 5-	XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, PAD, PAD, uxn_screen.width * ZOOM, uxn_screen.height * ZOOM);
 6+	XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, PAD, PAD, uxn_screen.width * SCALE, uxn_screen.height * SCALE);
 7 }
 8 
 9 static int
10@@ -166,7 +166,7 @@ emu_event(Uxn *u)
11 	} break;
12 	case MotionNotify: {
13 		XMotionEvent *e = (XMotionEvent *)&ev;
14-		mouse_pos(u, &u->dev[0x90], (e->x - PAD) / ZOOM, (e->y - PAD) / ZOOM);
15+		mouse_pos(u, &u->dev[0x90], (e->x - PAD) / SCALE, (e->y - PAD) / SCALE);
16 	} break;
17 	}
18 }
19@@ -177,7 +177,7 @@ display_start(char *title)
20 	Atom wmDelete;
21 	display = XOpenDisplay(NULL);
22 	visual = DefaultVisual(display, 0);
23-	window = XCreateSimpleWindow(display, RootWindow(display, 0), 0, 0, uxn_screen.width * ZOOM + PAD * 2, uxn_screen.height * ZOOM + PAD * 2, 1, 0, 0);
24+	window = XCreateSimpleWindow(display, RootWindow(display, 0), 0, 0, uxn_screen.width * SCALE + PAD * 2, uxn_screen.height * SCALE + PAD * 2, 1, 0, 0);
25 	if(visual->class != TrueColor)
26 		return system_error("init", "True-color visual failed");
27 	XSelectInput(display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask);
28@@ -185,7 +185,7 @@ display_start(char *title)
29 	XSetWMProtocols(display, window, &wmDelete, 1);
30 	XStoreName(display, window, title);
31 	XMapWindow(display, window);
32-	ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width * ZOOM, uxn_screen.height * ZOOM, 32, 0);
33+	ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width * SCALE, uxn_screen.height * SCALE, 32, 0);
34 	hide_cursor();
35 	return 1;
36 }