commit a67c290
Devine Lu Linvega
·
2025-04-08 23:34:32 +0000 UTC
parent 92954e5
Renamed scale to zoom
3 files changed,
+18,
-18
+6,
-8
1@@ -79,12 +79,10 @@ screen_apply(int width, int height)
2 }
3
4 void
5-screen_resize(int scale)
6+screen_resize(void)
7 {
8 Uint32 *pixels;
9- clamp(scale, 1, 3);
10- uxn_screen.pixels = realloc(uxn_screen.pixels, uxn_screen.width * uxn_screen.height * sizeof(Uint32) * scale * scale);
11- uxn_screen.scale = scale;
12+ uxn_screen.pixels = realloc(uxn_screen.pixels, uxn_screen.width * uxn_screen.height * sizeof(Uint32) * uxn_screen.zoom * uxn_screen.zoom);
13 uxn_screen.resize = 0;
14 emu_resize(uxn_screen.width, uxn_screen.height);
15 }
16@@ -94,12 +92,12 @@ screen_redraw(void)
17 {
18 int i, x, y, k, l;
19 for(y = uxn_screen.y1; y < uxn_screen.y2; y++) {
20- int ys = y * uxn_screen.scale;
21+ int ys = y * uxn_screen.zoom;
22 for(x = uxn_screen.x1, i = MAR(x) + MAR(y) * MAR2(uxn_screen.width); x < uxn_screen.x2; x++, i++) {
23 int c = uxn_screen.palette[uxn_screen.fg[i] << 2 | uxn_screen.bg[i]];
24- for(k = 0; k < uxn_screen.scale; k++) {
25- int oo = ((ys + k) * uxn_screen.width + x) * uxn_screen.scale;
26- for(l = 0; l < uxn_screen.scale; l++)
27+ for(k = 0; k < uxn_screen.zoom; k++) {
28+ int oo = ((ys + k) * uxn_screen.width + x) * uxn_screen.zoom;
29+ for(l = 0; l < uxn_screen.zoom; l++)
30 uxn_screen.pixels[oo + l] = c;
31 }
32 }
+2,
-2
1@@ -10,7 +10,7 @@ WITH REGARD TO THIS SOFTWARE.
2 */
3
4 typedef struct UxnScreen {
5- int width, height, resize, vector, scale, x1, y1, x2, y2;
6+ int width, height, resize, vector, zoom, x1, y1, x2, y2;
7 Uint32 palette[16], *pixels;
8 Uint8 *fg, *bg;
9 } UxnScreen;
10@@ -20,7 +20,7 @@ extern int emu_resize(int width, int height);
11 int screen_changed(void);
12 void screen_palette(void);
13 void screen_apply(int width, int height);
14-void screen_resize(int scale);
15+void screen_resize(void);
16 void screen_redraw(void);
17
18 Uint8 screen_dei(Uint8 addr);
+10,
-8
1@@ -73,12 +73,12 @@ emu_deo(Uint8 addr, Uint8 value)
2 int
3 emu_resize(int width, int height)
4 {
5- width *= uxn_screen.scale, height *= uxn_screen.scale;
6+ width *= uxn_screen.zoom, height *= uxn_screen.zoom;
7 XResizeWindow(display, window, width, height);
8 ximage = XCreateImage(display, DefaultVisual(display, 0), DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, width, height, 32, 0);
9 if(screen_changed()) {
10- int x = uxn_screen.x1 * uxn_screen.scale, y = uxn_screen.y1 * uxn_screen.scale;
11- int w = uxn_screen.x2 * uxn_screen.scale - x, h = uxn_screen.y2 * uxn_screen.scale - y;
12+ int x = uxn_screen.x1 * uxn_screen.zoom, y = uxn_screen.y1 * uxn_screen.zoom;
13+ int w = uxn_screen.x2 * uxn_screen.zoom - x, h = uxn_screen.y2 * uxn_screen.zoom - y;
14 screen_redraw();
15 XPutImage(display, window, DefaultGC(display, 0), ximage, x, y, x, y, w, h);
16 }
17@@ -96,7 +96,8 @@ emu_restart(int soft)
18 static void
19 emu_rescale(void)
20 {
21- screen_resize(uxn_screen.scale >= 3 ? 1 : uxn_screen.scale + 1);
22+ uxn_screen.zoom = uxn_screen.zoom >= 3 ? 1 : uxn_screen.zoom + 1;
23+ screen_resize();
24 }
25
26 static Uint8
27@@ -168,7 +169,7 @@ emu_event(void)
28 case LeaveNotify:
29 case MotionNotify: {
30 XMotionEvent *e = (XMotionEvent *)&ev;
31- mouse_pos(e->x / uxn_screen.scale, e->y / uxn_screen.scale);
32+ mouse_pos(e->x / uxn_screen.zoom, e->y / uxn_screen.zoom);
33 } break;
34 }
35 }
36@@ -216,6 +217,7 @@ display_init(void)
37 XSetClassHint(display, window, &class);
38 XMapWindow(display, window);
39 screen_apply(WIDTH, HEIGHT);
40+ uxn_screen.zoom = 1;
41 return 1;
42 }
43
44@@ -241,12 +243,12 @@ emu_run(void)
45 if(poll(&fds[1], 1, 0)) {
46 read(fds[1].fd, expirations, 8);
47 if(uxn_screen.resize)
48- screen_resize(uxn_screen.scale);
49+ screen_resize();
50 if(uxn_screen.vector)
51 uxn_eval(uxn_screen.vector);
52 if(uxn_screen.x2 && uxn_screen.y2 && screen_changed()) {
53- int x = uxn_screen.x1 * uxn_screen.scale, y = uxn_screen.y1 * uxn_screen.scale;
54- int w = uxn_screen.x2 * uxn_screen.scale - x, h = uxn_screen.y2 * uxn_screen.scale - y;
55+ int x = uxn_screen.x1 * uxn_screen.zoom, y = uxn_screen.y1 * uxn_screen.zoom;
56+ int w = uxn_screen.x2 * uxn_screen.zoom - x, h = uxn_screen.y2 * uxn_screen.zoom - y;
57 screen_redraw();
58 XPutImage(display, window, DefaultGC(display, 0), ximage, x, y, x, y, w, h);
59 }