commit 4042ce0
Devie Lu Linvega
·
2025-12-23 18:07:18 +0000 UTC
parent 51679ef
Removed screen struct
1 files changed,
+30,
-35
+30,
-35
1@@ -166,7 +166,6 @@ system_boot(char *rom_path, const unsigned int has_args)
2 static unsigned int
3 system_reboot(const unsigned int soft)
4 {
5- unsigned int i;
6 memset(dev, 0, 0x100);
7 memset(stk[0], 0, 0x100);
8 memset(stk[1], 0, 0x100);
9@@ -410,15 +409,11 @@ console_input(int c, unsigned int type)
10 #define MAR(x) (x + 0x8)
11 #define MAR2(x) (x + 0x10)
12
13-typedef struct UxnScreen {
14- int width, height;
15-} UxnScreen;
16-
17+static int screen_width, screen_height;
18 static int screen_resized, screen_full, screen_zoom;
19 static int screen_x1, screen_y1, screen_x2, screen_y2;
20 static unsigned int screen_vector, *screen_pixels, screen_palette[16];
21 static Uint8 *screen_layers;
22-static UxnScreen uxn_screen;
23
24 static const Uint8 blending[16][4] = {
25 {0, 0, 1, 2},
26@@ -468,12 +463,12 @@ screen_colorize(void)
27 static void
28 screen_resize(int width, int height)
29 {
30- if(width != uxn_screen.width || height != uxn_screen.height) {
31+ if(width != screen_width || height != screen_height) {
32 int length = MAR2(width) * MAR2(height);
33 screen_layers = realloc(screen_layers, length);
34 memset(screen_layers, 0, length);
35- uxn_screen.width = width;
36- uxn_screen.height = height;
37+ screen_width = width;
38+ screen_height = height;
39 screen_resized = 1;
40 screen_full = 1;
41 }
42@@ -489,10 +484,10 @@ scree_redraw(void)
43 int i, x, y, k, l;
44 for(y = screen_y1; y < screen_y2; y++) {
45 const int ys = y * screen_zoom;
46- for(x = screen_x1, i = MAR(x) + MAR(y) * MAR2(uxn_screen.width); x < screen_x2; x++, i++) {
47+ for(x = screen_x1, i = MAR(x) + MAR(y) * MAR2(screen_width); x < screen_x2; x++, i++) {
48 const int c = screen_palette[screen_layers[i]];
49 for(k = 0; k < screen_zoom; k++) {
50- const int oo = ((ys + k) * uxn_screen.width + x) * screen_zoom;
51+ const int oo = ((ys + k) * screen_width + x) * screen_zoom;
52 for(l = 0; l < screen_zoom; l++)
53 screen_pixels[oo + l] = c;
54 }
55@@ -508,9 +503,9 @@ screen_update(void)
56 if(screen_vector)
57 uxn_eval(screen_vector);
58 if(screen_resized) {
59- const int width = uxn_screen.width * screen_zoom;
60- const int height = uxn_screen.height * screen_zoom;
61- const int length = uxn_screen.width * uxn_screen.height * sizeof(unsigned int) * screen_zoom * screen_zoom;
62+ const int width = screen_width * screen_zoom;
63+ const int height = screen_height * screen_zoom;
64+ const int length = screen_width * screen_height * sizeof(unsigned int) * screen_zoom * screen_zoom;
65 XResizeWindow(display, window, width, height);
66 screen_pixels = realloc(screen_pixels, length);
67 if(ximage)
68@@ -521,14 +516,14 @@ screen_update(void)
69 }
70 if(screen_full) {
71 screen_x1 = screen_y1 = 0;
72- screen_x2 = uxn_screen.width;
73- screen_y2 = uxn_screen.height;
74+ screen_x2 = screen_width;
75+ screen_y2 = screen_height;
76 scree_redraw();
77 } else if(screen_x2 > screen_x1 && screen_y2 > screen_y1) {
78- CLAMP(screen_x1, 0, uxn_screen.width);
79- CLAMP(screen_y1, 0, uxn_screen.height);
80- CLAMP(screen_x2, 0, uxn_screen.width);
81- CLAMP(screen_y2, 0, uxn_screen.height);
82+ CLAMP(screen_x1, 0, screen_width);
83+ CLAMP(screen_y1, 0, screen_height);
84+ CLAMP(screen_x2, 0, screen_width);
85+ CLAMP(screen_y2, 0, screen_height);
86 scree_redraw();
87 }
88 }
89@@ -541,7 +536,7 @@ static void
90 screen_draw_pixel(void)
91 {
92 const int ctrl = dev[0x2e];
93- const int len = MAR2(uxn_screen.width);
94+ const int len = MAR2(screen_width);
95 const int above = ctrl & 0x40;
96 const int color = above ? (ctrl & 0x3) << 2 : ctrl & 0x3;
97 /* fill mode */
98@@ -550,11 +545,11 @@ screen_draw_pixel(void)
99 if(ctrl & 0x10)
100 x1 = 0, x2 = rX;
101 else
102- x1 = rX, x2 = uxn_screen.width;
103+ x1 = rX, x2 = screen_width;
104 if(ctrl & 0x20)
105 y1 = 0, y2 = rY;
106 else
107- y1 = rY, y2 = uxn_screen.height;
108+ y1 = rY, y2 = screen_height;
109 screen_full = 1;
110 x1 = MAR(x1), y1 = MAR(y1);
111 hor = MAR(x2) - x1, ver = MAR(y2) - y1;
112@@ -566,7 +561,7 @@ screen_draw_pixel(void)
113 }
114 /* pixel mode */
115 else {
116- if(rX >= 0 && rY >= 0 && rX < len && rY < uxn_screen.height) {
117+ if(rX >= 0 && rY >= 0 && rX < len && rY < screen_height) {
118 const int ax = MAR(rX) + MAR(rY) * len;
119 const int src = screen_layers[ax];
120 screen_layers[ax] = above ? (src & 0x3) | color : (src & 0xc) | color;
121@@ -587,8 +582,8 @@ screen_draw_sprite(void)
122 const int fx = ctrl & 0x10 ? -1 : 1, fy = ctrl & 0x20 ? -1 : 1;
123 const int qfx = fx > 0 ? 7 : 0, qfy = fy < 0 ? 7 : 0;
124 const int dxy = fy * rDX, dyx = fx * rDY;
125- const int wmar = MAR(uxn_screen.width), wmar2 = MAR2(uxn_screen.width);
126- const int hmar2 = MAR2(uxn_screen.height);
127+ const int wmar = MAR(screen_width), wmar2 = MAR2(screen_width);
128+ const int hmar2 = MAR2(screen_height);
129 const Uint8 *table = blending[blend];
130 int i, x1, x2, y1, y2, ax, ay, qx, qy, x = rX, y = rY;
131 if(ctrl & 0x80) {
132@@ -983,10 +978,10 @@ emu_dei(const Uint8 port)
133 case CMD_LIVE:
134 case CMD_EXIT: check_child(); break;
135 /* Screen */
136- case 0x22: return uxn_screen.width >> 8;
137- case 0x23: return uxn_screen.width;
138- case 0x24: return uxn_screen.height >> 8;
139- case 0x25: return uxn_screen.height;
140+ case 0x22: return screen_width >> 8;
141+ case 0x23: return screen_width;
142+ case 0x24: return screen_height >> 8;
143+ case 0x25: return screen_height;
144 case 0x28: return rX >> 8;
145 case 0x29: return rX;
146 case 0x2a: return rY >> 8;
147@@ -1033,8 +1028,8 @@ emu_deo(const Uint8 port, const Uint8 value)
148 case 0x1f: console_start_fork(); return;
149 /* Screen */
150 case 0x21: screen_vector = PEEK2(&dev[0x20]); return;
151- case 0x23: screen_resize(PEEK2(&dev[0x22]) & 0xfff, uxn_screen.height & 0xfff); return;
152- case 0x25: screen_resize(uxn_screen.width & 0xfff, PEEK2(&dev[0x24]) & 0xfff); return;
153+ case 0x23: screen_resize(PEEK2(&dev[0x22]) & 0xfff, screen_height & 0xfff); return;
154+ case 0x25: screen_resize(screen_width & 0xfff, PEEK2(&dev[0x24]) & 0xfff); return;
155 case 0x26: rMX = dev[0x26] & 0x1, rMY = dev[0x26] & 0x2, rMA = dev[0x26] & 0x4, rML = dev[0x26] >> 4, rDX = rMX << 3, rDY = rMY << 2; return;
156 case 0x28:
157 case 0x29: rX = (dev[0x28] << 8) | dev[0x29], rX = TWOS(rX); return;
158@@ -1119,7 +1114,7 @@ display_init(void)
159 Screen *screen;
160 Visual *visual;
161 XClassHint class = {"uxn11", "Uxn"};
162- int screen_width, screen_height;
163+ int desktop_width, desktop_height;
164 /* start display */
165 display = XOpenDisplay(NULL);
166 if(!display)
167@@ -1130,8 +1125,8 @@ display_init(void)
168 return !fprintf(stderr, "Display: True-color visual failed\n");
169 /* center */
170 screen = ScreenOfDisplay(display, 0);
171- screen_width = screen->width, screen_height = screen->height;
172- window = XCreateSimpleWindow(display, RootWindow(display, 0), screen_width / 2 - uxn_screen.width / 2, screen_height / 2 - uxn_screen.height / 2, uxn_screen.width, uxn_screen.height, 1, 0, 0);
173+ desktop_width = screen->width, desktop_height = screen->height;
174+ window = XCreateSimpleWindow(display, RootWindow(display, 0), desktop_width / 2 - screen_width / 2, desktop_height / 2 - screen_height / 2, screen_width, screen_height, 1, 0, 0);
175 display_hidecursor();
176 display_floating(display, window);
177 XSelectInput(display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask | LeaveWindowMask);