commit 89c3a89
Devie Lu Linvega
·
2025-12-23 17:59:30 +0000 UTC
parent d3074c4
Cleanup
1 files changed,
+17,
-18
+17,
-18
1@@ -412,11 +412,10 @@ console_input(int c, unsigned int type)
2
3 typedef struct UxnScreen {
4 int width, height, zoom, resized, full, x1, y1, x2, y2;
5- unsigned int palette[16];
6- Uint8 *bg;
7 } UxnScreen;
8
9-static unsigned int screen_vector, *screen_pixels;
10+static Uint8 *screen_layers;
11+static unsigned int screen_vector, *screen_pixels, screen_palette[16];
12 static UxnScreen uxn_screen;
13
14 static const Uint8 blending[16][4] = {
15@@ -448,7 +447,7 @@ screen_change(const int x1, const int y1, const int x2, const int y2)
16 }
17
18 static void
19-screen_palette(void)
20+screen_colorize(void)
21 {
22 int i, shift, colors[4];
23 for(i = 0, shift = 4; i < 4; ++i, shift ^= 4) {
24@@ -460,7 +459,7 @@ screen_palette(void)
25 colors[i] |= colors[i] << 4;
26 }
27 for(i = 0; i < 16; i++)
28- uxn_screen.palette[i] = colors[(i >> 2) ? (i >> 2) : (i & 3)];
29+ screen_palette[i] = colors[(i >> 2) ? (i >> 2) : (i & 3)];
30 uxn_screen.full = 1;
31 }
32
33@@ -469,8 +468,8 @@ screen_resize(int width, int height)
34 {
35 if(width != uxn_screen.width || height != uxn_screen.height) {
36 int length = MAR2(width) * MAR2(height);
37- uxn_screen.bg = realloc(uxn_screen.bg, length);
38- memset(uxn_screen.bg, 0, length);
39+ screen_layers = realloc(screen_layers, length);
40+ memset(screen_layers, 0, length);
41 uxn_screen.width = width;
42 uxn_screen.height = height;
43 uxn_screen.resized = 1;
44@@ -489,7 +488,7 @@ scree_redraw(void)
45 for(y = uxn_screen.y1; y < uxn_screen.y2; y++) {
46 const int ys = y * uxn_screen.zoom;
47 for(x = uxn_screen.x1, i = MAR(x) + MAR(y) * MAR2(uxn_screen.width); x < uxn_screen.x2; x++, i++) {
48- const int c = uxn_screen.palette[uxn_screen.bg[i]];
49+ const int c = screen_palette[screen_layers[i]];
50 for(k = 0; k < uxn_screen.zoom; k++) {
51 const int oo = ((ys + k) * uxn_screen.width + x) * uxn_screen.zoom;
52 for(l = 0; l < uxn_screen.zoom; l++)
53@@ -502,7 +501,7 @@ scree_redraw(void)
54 }
55
56 static void
57-screen_update()
58+screen_update(void)
59 {
60 if(screen_vector)
61 uxn_eval(screen_vector);
62@@ -559,16 +558,16 @@ screen_draw_pixel(void)
63 hor = MAR(x2) - x1, ver = MAR(y2) - y1;
64 for(ay = y1 * len, by = ay + ver * len; ay < by; ay += len)
65 for(ax = ay + x1, bx = ax + hor; ax < bx; ax++) {
66- const int src = uxn_screen.bg[ax];
67- uxn_screen.bg[ax] = above ? (src & 0x3) | color : (src & 0xc) | color;
68+ const int src = screen_layers[ax];
69+ screen_layers[ax] = above ? (src & 0x3) | color : (src & 0xc) | color;
70 }
71 }
72 /* pixel mode */
73 else {
74 if(rX >= 0 && rY >= 0 && rX < len && rY < uxn_screen.height) {
75 const int ax = MAR(rX) + MAR(rY) * len;
76- const int src = uxn_screen.bg[ax];
77- uxn_screen.bg[ax] = above ? (src & 0x3) | color : (src & 0xc) | color;
78+ const int src = screen_layers[ax];
79+ screen_layers[ax] = above ? (src & 0x3) | color : (src & 0xc) | color;
80 }
81 if(!uxn_screen.full) screen_change(rX, rY, rX + 1, rY + 1);
82 if(rMX) rX++;
83@@ -603,8 +602,8 @@ screen_draw_sprite(void)
84 for(ax = xmar + ay, qx = qfx; ax < bx; ax++, qx -= fx) {
85 const int color = ((ch1 >> qx) & 1) | ((ch2 >> qx) & 2);
86 if(opaque || color) {
87- const int src = uxn_screen.bg[ax];
88- uxn_screen.bg[ax] = above ? (src & 0x3) | table[color] << 2 : (src & 0xc) | table[color];
89+ const int src = screen_layers[ax];
90+ screen_layers[ax] = above ? (src & 0x3) | table[color] << 2 : (src & 0xc) | table[color];
91 }
92 }
93 }
94@@ -623,8 +622,8 @@ screen_draw_sprite(void)
95 for(ax = xmar + ay, qx = qfx; ax < bx; ax++, qx -= fx) {
96 const int color = (ch1 >> qx) & 1;
97 if(opaque || color) {
98- const int src = uxn_screen.bg[ax];
99- uxn_screen.bg[ax] = above ? (src & 0x3) | table[color] << 2 : (src & 0xc) | table[color];
100+ const int src = screen_layers[ax];
101+ screen_layers[ax] = above ? (src & 0x3) | table[color] << 2 : (src & 0xc) | table[color];
102 }
103 }
104 }
105@@ -1021,7 +1020,7 @@ emu_deo(const Uint8 port, const Uint8 value)
106 case 0x0a:
107 case 0x0b:
108 case 0x0c:
109- case 0x0d: screen_palette(); return;
110+ case 0x0d: screen_colorize(); return;
111 case 0x0e: system_print("WST", 0), system_print("RST", 1); return;
112 /* Console */
113 case 0x11: console_vector = PEEK2(&dev[0x10]); return;