commit 8d21963
Devine Lu Linvega
·
2025-04-09 00:00:34 +0000 UTC
parent 8aeda81
Cleanup
3 files changed,
+26,
-27
+1,
-1
1@@ -39,7 +39,7 @@ screen_changed(void)
2 uxn_screen.y2 > uxn_screen.y1;
3 }
4
5-static void
6+void
7 screen_change(int x1, int y1, int x2, int y2)
8 {
9 if(x1 < uxn_screen.x1) uxn_screen.x1 = x1;
+1,
-1
1@@ -16,7 +16,7 @@ typedef struct UxnScreen {
2 } UxnScreen;
3
4 extern UxnScreen uxn_screen;
5-extern int emu_resize(int width, int height);
6+void screen_change(int x1, int y1, int x2, int y2);
7 int screen_changed(void);
8 void screen_palette(void);
9 void screen_apply(int width, int height);
+24,
-25
1@@ -70,23 +70,29 @@ emu_deo(Uint8 addr, Uint8 value)
2 }
3 }
4
5-int
6-emu_resize(int width, int height)
7+void
8+emu_repaint(void)
9 {
10- Uint32 *pixels;
11- uxn_screen.pixels = realloc(uxn_screen.pixels, uxn_screen.width * uxn_screen.height * sizeof(Uint32) * uxn_screen.zoom * uxn_screen.zoom);
12- uxn_screen.resize = 0;
13+ int x = uxn_screen.x1 * uxn_screen.zoom;
14+ int y = uxn_screen.y1 * uxn_screen.zoom;
15+ int w = uxn_screen.x2 * uxn_screen.zoom - x;
16+ int h = uxn_screen.y2 * uxn_screen.zoom - y;
17+ screen_redraw();
18+ XPutImage(display, window, DefaultGC(display, 0), ximage, x, y, x, y, w, h);
19+}
20
21- width *= uxn_screen.zoom, height *= uxn_screen.zoom;
22+void
23+emu_resize(void)
24+{
25+ int width = uxn_screen.width * uxn_screen.zoom;
26+ int height = uxn_screen.height * uxn_screen.zoom;
27 XResizeWindow(display, window, width, height);
28+ uxn_screen.pixels = realloc(uxn_screen.pixels,
29+ uxn_screen.width * uxn_screen.height * sizeof(Uint32) * uxn_screen.zoom * uxn_screen.zoom);
30 ximage = XCreateImage(display, DefaultVisual(display, 0), DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, width, height, 32, 0);
31- if(screen_changed()) {
32- int x = uxn_screen.x1 * uxn_screen.zoom, y = uxn_screen.y1 * uxn_screen.zoom;
33- int w = uxn_screen.x2 * uxn_screen.zoom - x, h = uxn_screen.y2 * uxn_screen.zoom - y;
34- screen_redraw();
35- XPutImage(display, window, DefaultGC(display, 0), ximage, x, y, x, y, w, h);
36- }
37- return 1;
38+ if(screen_changed())
39+ emu_repaint();
40+ uxn_screen.resize = 0;
41 }
42
43 static void
44@@ -101,7 +107,7 @@ static void
45 emu_rescale(void)
46 {
47 uxn_screen.zoom = uxn_screen.zoom >= 3 ? 1 : uxn_screen.zoom + 1;
48- emu_resize(uxn_screen.width, uxn_screen.height);
49+ emu_resize();
50 }
51
52 static Uint8
53@@ -129,10 +135,7 @@ emu_event(void)
54 XNextEvent(display, &ev);
55 switch(ev.type) {
56 case Expose:
57- /* uxn_screen.x1 = uxn_screen.y1 = 0;
58- uxn_screen.x2 = uxn_screen.width;
59- uxn_screen.y2 = uxn_screen.height;
60- emu_resize(uxn_screen.width, uxn_screen.height); */
61+ screen_change(0, 0, 9000, 9000);
62 break;
63 case ClientMessage:
64 uxn.dev[0x0f] = 0x80;
65@@ -247,15 +250,11 @@ emu_run(void)
66 if(poll(&fds[1], 1, 0)) {
67 read(fds[1].fd, expirations, 8);
68 if(uxn_screen.resize)
69- emu_resize(uxn_screen.width, uxn_screen.height);
70+ emu_resize();
71 if(uxn_screen.vector)
72 uxn_eval(uxn_screen.vector);
73- if(uxn_screen.x2 && uxn_screen.y2 && screen_changed()) {
74- int x = uxn_screen.x1 * uxn_screen.zoom, y = uxn_screen.y1 * uxn_screen.zoom;
75- int w = uxn_screen.x2 * uxn_screen.zoom - x, h = uxn_screen.y2 * uxn_screen.zoom - y;
76- screen_redraw();
77- XPutImage(display, window, DefaultGC(display, 0), ximage, x, y, x, y, w, h);
78- }
79+ if(uxn_screen.x2 && uxn_screen.y2 && screen_changed())
80+ emu_repaint();
81 }
82 has_input = fds[2].revents & POLLIN;
83 has_eof = fds[2].revents & POLLHUP;