commit f3e0b86
Devie Lu Linvega
·
2025-12-26 18:31:18 +0000 UTC
parent 21b3969
Cleanup
1 files changed,
+44,
-36
+44,
-36
1@@ -214,6 +214,17 @@ system_expansion(const Uint16 exp)
2 #define CONSOLE_EOA 0x3
3 #define CONSOLE_END 0x4
4
5+static unsigned int console_vector;
6+
7+static unsigned int
8+console_input(int c, unsigned int type)
9+{
10+ if(c == EOF) c = 0, type = CONSOLE_END;
11+ dev[0x12] = c, dev[0x17] = type;
12+ if(console_vector) uxn_eval(console_vector);
13+ return type != CONSOLE_END;
14+}
15+
16 #undef _POSIX_C_SOURCE
17 #define _POSIX_C_SOURCE 200112L
18
19@@ -231,8 +242,6 @@ system_expansion(const Uint16 exp)
20 #include <util.h>
21 #endif
22
23-static unsigned int console_vector;
24-
25 /* subprocess support */
26 static char *fork_args[4] = {"/bin/sh", "-c", "", NULL};
27 static int child_mode;
28@@ -392,25 +401,20 @@ console_close(void)
29 kill_child();
30 }
31
32-static unsigned int
33-console_input(int c, unsigned int type)
34-{
35- if(c == EOF) c = 0, type = 4;
36- dev[0x12] = c, dev[0x17] = type;
37- if(console_vector) uxn_eval(console_vector);
38- return type != 4;
39-}
40-
41 /*
42 @|Screen ------------------------------------------------------------ */
43
44 #define MAR(x) (x + 0x8)
45 #define MAR2(x) (x + 0x10)
46
47+static Uint8 *screen_layers;
48 static int screen_width, screen_height, screen_zoom;
49 static int screen_x1, screen_y1, screen_x2, screen_y2, screen_reqsize, screen_reqdraw;
50 static unsigned int screen_vector, *screen_pixels, screen_palette[16];
51-static Uint8 *screen_layers;
52+static int rX, rY, rA, rMX, rMY, rMA, rML, rDX, rDY;
53+
54+void emu_redraw(void);
55+void emu_resize(void);
56
57 static const Uint8 blending[16][2][4] = {
58 {{0, 0, 1, 2}, {0, 0, 4, 8}},
59@@ -465,18 +469,13 @@ screen_resize(int width, int height)
60 memset(screen_layers, 0, length);
61 screen_width = width;
62 screen_height = height;
63- screen_reqsize = 1;
64- screen_reqdraw = 1;
65+ screen_reqsize = screen_reqdraw = 1;
66 }
67 }
68
69 static void
70-scree_redraw(void)
71+screen_redraw(void)
72 {
73- const int ax = screen_x1 * screen_zoom;
74- const int ay = screen_y1 * screen_zoom;
75- const int aw = screen_x2 * screen_zoom - ax;
76- const int ah = screen_y2 * screen_zoom - ay;
77 int i, x, y, k, l;
78 for(y = screen_y1; y < screen_y2; y++) {
79 const int ys = y * screen_zoom;
80@@ -489,7 +488,7 @@ scree_redraw(void)
81 }
82 }
83 }
84- XPutImage(display, window, DefaultGC(display, 0), ximage, ax, ay, ax, ay, aw, ah);
85+ emu_redraw();
86 screen_x1 = screen_y1 = screen_x2 = screen_y2 = screen_reqdraw = 0;
87 }
88
89@@ -499,35 +498,24 @@ screen_update(void)
90 if(screen_vector)
91 uxn_eval(screen_vector);
92 if(screen_reqsize) {
93- const int width = screen_width * screen_zoom;
94- const int height = screen_height * screen_zoom;
95- const int length = screen_width * screen_height * sizeof(unsigned int) * screen_zoom * screen_zoom;
96- XResizeWindow(display, window, width, height);
97- screen_pixels = realloc(screen_pixels, length);
98- if(ximage)
99- free(ximage);
100- ximage = XCreateImage(display, DefaultVisual(display, 0), DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)screen_pixels, width, height, 32, 0);
101- screen_reqdraw = 1;
102+ screen_pixels = realloc(screen_pixels, screen_width * screen_height * sizeof(unsigned int) * screen_zoom * screen_zoom);
103 screen_reqsize = 0;
104+ emu_resize();
105 }
106 if(screen_reqdraw) {
107 screen_x1 = screen_y1 = 0;
108 screen_x2 = screen_width;
109 screen_y2 = screen_height;
110- scree_redraw();
111+ screen_redraw();
112 } else if(screen_x2 > screen_x1 && screen_y2 > screen_y1) {
113 CLAMP(screen_x1, 0, screen_width);
114 CLAMP(screen_y1, 0, screen_height);
115 CLAMP(screen_x2, 0, screen_width);
116 CLAMP(screen_y2, 0, screen_height);
117- scree_redraw();
118+ screen_redraw();
119 }
120 }
121
122-/* screen registers */
123-
124-static int rX, rY, rA, rMX, rMY, rMA, rML, rDX, rDY;
125-
126 static void
127 screen_draw_pixel(void)
128 {
129@@ -1061,6 +1049,26 @@ emu_deo(const Uint8 port, const Uint8 value)
130 }
131 }
132
133+void
134+emu_resize(void)
135+{
136+ const int width = screen_width * screen_zoom;
137+ const int height = screen_height * screen_zoom;
138+ if(ximage) free(ximage);
139+ ximage = XCreateImage(display, DefaultVisual(display, 0), DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)screen_pixels, width, height, 32, 0);
140+ XResizeWindow(display, window, width, height);
141+}
142+
143+void
144+emu_redraw(void)
145+{
146+ const int ax = screen_x1 * screen_zoom;
147+ const int ay = screen_y1 * screen_zoom;
148+ const int aw = screen_x2 * screen_zoom - ax;
149+ const int ah = screen_y2 * screen_zoom - ay;
150+ XPutImage(display, window, DefaultGC(display, 0), ximage, ax, ay, ax, ay, aw, ah);
151+}
152+
153 static void
154 emu_restart(unsigned int soft)
155 {
156@@ -1151,7 +1159,7 @@ emu_event(void)
157 KeySym sym;
158 XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0);
159 switch(sym) {
160- case XK_F1: screen_zoom = (screen_zoom % 3) + 1, screen_reqsize = 1; break;
161+ case XK_F1: screen_zoom = (screen_zoom % 3) + 1, screen_reqsize = screen_reqdraw = 1; break;
162 case XK_F2: emu_deo(0xe, 0x1); break;
163 case XK_F4: emu_restart(0); break;
164 case XK_F5: emu_restart(1); break;