commit b72cfa7
Devine Lu Linvega
·
2026-01-08 22:47:52 +0000 UTC
parent da1e441
Prestore all the port pointers
2 files changed,
+69,
-74
M
makefile
M
makefile
+1,
-1
1@@ -1,5 +1,5 @@
2 RELEASE_flags=-DNDEBUG -O2 -g0 -s
3-DEBUG_flags=-std=c89 -D_POSIX_C_SOURCE=199309L -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined
4+DEBUG_flags=-std=c99 -D_POSIX_C_SOURCE=199309L -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined
5 PREFIX=${HOME}/.local
6
7 run: bin/uxn11 bin/perifs.rom
+68,
-73
1@@ -33,8 +33,6 @@ static XImage *emu_img;
2 static int emu_x11;
3 static int emu_timer;
4
5-static deo_handler deo_handlers[256];
6-static dei_handler dei_handlers[256];
7 static Uint8 *ram, dev[0x100], ptr[2], stk[2][0x100];
8
9 static Uint8 emu_dei(const Uint8 port);
10@@ -1043,77 +1041,75 @@ Uint8 datetime_dei_dst(void) { datetime_update(); return datetime_t->tm_isdst; }
11 /*
12 @|Core -------------------------------------------------------------- */
13
14-#define CONINBUFSIZE 256
15+static const dei_handler dei_handlers[256] = {
16+ [0x04] = system_dei_wst,
17+ [0x05] = system_dei_rst,
18+ [0x15] = console_dei_childlive,
19+ [0x16] = console_dei_childexit,
20+ [0x28] = screen_dei_rxhb,
21+ [0x29] = screen_dei_rxlb,
22+ [0x2a] = screen_dei_ryhb,
23+ [0x2b] = screen_dei_rylb,
24+ [0x2c] = screen_dei_rahb,
25+ [0x2d] = screen_dei_ralb,
26+ [0xc0] = datetime_dei_yhb,
27+ [0xc1] = datetime_dei_ylb,
28+ [0xc2] = datetime_dei_mon,
29+ [0xc3] = datetime_dei_day,
30+ [0xc4] = datetime_dei_hou,
31+ [0xc5] = datetime_dei_min,
32+ [0xc6] = datetime_dei_sec,
33+ [0xc7] = datetime_dei_wday,
34+ [0xc8] = datetime_dei_ydayhb,
35+ [0xc9] = datetime_dei_ydaylb,
36+ [0xca] = datetime_dei_dst,
37+};
38+
39+static const deo_handler deo_handlers[256] = {
40+ [0x03] = system_deo_expansion,
41+ [0x04] = system_deo_wst,
42+ [0x05] = system_deo_rst,
43+ [0x08] = system_deo_colorize,
44+ [0x09] = system_deo_colorize,
45+ [0x0a] = system_deo_colorize,
46+ [0x0b] = system_deo_colorize,
47+ [0x0c] = system_deo_colorize,
48+ [0x0d] = system_deo_colorize,
49+ [0x0e] = system_deo_print,
50+ [0x11] = console_deo_vector,
51+ [0x18] = console_deo_stdout,
52+ [0x19] = console_deo_stderr,
53+ [0x1a] = console_deo_hb,
54+ [0x1b] = console_deo_lb,
55+ [0x1f] = console_deo_fork,
56+ [0x21] = screen_deo_vector,
57+ [0x23] = screen_deo_width,
58+ [0x25] = screen_deo_height,
59+ [0x26] = screen_deo_auto,
60+ [0x28] = screen_deo_x,
61+ [0x29] = screen_deo_x,
62+ [0x2a] = screen_deo_y,
63+ [0x2b] = screen_deo_y,
64+ [0x2c] = screen_deo_addr,
65+ [0x2d] = screen_deo_addr,
66+ [0x2e] = screen_deo_pixel,
67+ [0x2f] = screen_deo_sprite,
68+ [0x81] = controller_deo_vector,
69+ [0x91] = mouse_deo_vector,
70+ [0xab] = filea_deo_vector,
71+ [0xa5] = filea_deo_stat,
72+ [0xa6] = filea_deo_delete,
73+ [0xa9] = filea_deo_name,
74+ [0xad] = filea_deo_read,
75+ [0xaf] = filea_deo_write,
76+ [0xbb] = filea_deo_vector,
77+ [0xb5] = filea_deo_stat,
78+ [0xb6] = filea_deo_delete,
79+ [0xb9] = filea_deo_name,
80+ [0xbd] = filea_deo_read,
81+ [0xbf] = filea_deo_write};
82
83-void
84-emu_connect(void)
85-{
86- /* DEI */
87- dei_handlers[0x04] = system_dei_wst;
88- dei_handlers[0x05] = system_dei_rst;
89- dei_handlers[0x15] = console_dei_childlive;
90- dei_handlers[0x16] = console_dei_childexit;
91- dei_handlers[0x28] = screen_dei_rxhb;
92- dei_handlers[0x29] = screen_dei_rxlb;
93- dei_handlers[0x2a] = screen_dei_ryhb;
94- dei_handlers[0x2b] = screen_dei_rylb;
95- dei_handlers[0x2c] = screen_dei_rahb;
96- dei_handlers[0x2d] = screen_dei_ralb;
97- dei_handlers[0xc0] = datetime_dei_yhb;
98- dei_handlers[0xc1] = datetime_dei_ylb;
99- dei_handlers[0xc2] = datetime_dei_mon;
100- dei_handlers[0xc3] = datetime_dei_day;
101- dei_handlers[0xc4] = datetime_dei_hou;
102- dei_handlers[0xc5] = datetime_dei_min;
103- dei_handlers[0xc6] = datetime_dei_sec;
104- dei_handlers[0xc7] = datetime_dei_wday;
105- dei_handlers[0xc8] = datetime_dei_ydayhb;
106- dei_handlers[0xc9] = datetime_dei_ydaylb;
107- dei_handlers[0xca] = datetime_dei_dst;
108- /* DEO */
109- deo_handlers[0x03] = system_deo_expansion;
110- deo_handlers[0x04] = system_deo_wst;
111- deo_handlers[0x05] = system_deo_rst;
112- deo_handlers[0x08] = system_deo_colorize;
113- deo_handlers[0x09] = system_deo_colorize;
114- deo_handlers[0x0a] = system_deo_colorize;
115- deo_handlers[0x0b] = system_deo_colorize;
116- deo_handlers[0x0c] = system_deo_colorize;
117- deo_handlers[0x0d] = system_deo_colorize;
118- deo_handlers[0x0e] = system_deo_print;
119- deo_handlers[0x11] = console_deo_vector;
120- deo_handlers[0x18] = console_deo_stdout;
121- deo_handlers[0x19] = console_deo_stderr;
122- deo_handlers[0x1a] = console_deo_hb;
123- deo_handlers[0x1b] = console_deo_lb;
124- deo_handlers[0x1f] = console_deo_fork;
125- deo_handlers[0x21] = screen_deo_vector;
126- deo_handlers[0x23] = screen_deo_width;
127- deo_handlers[0x25] = screen_deo_height;
128- deo_handlers[0x26] = screen_deo_auto;
129- deo_handlers[0x28] = screen_deo_x;
130- deo_handlers[0x29] = screen_deo_x;
131- deo_handlers[0x2a] = screen_deo_y;
132- deo_handlers[0x2b] = screen_deo_y;
133- deo_handlers[0x2c] = screen_deo_addr;
134- deo_handlers[0x2d] = screen_deo_addr;
135- deo_handlers[0x2e] = screen_deo_pixel;
136- deo_handlers[0x2f] = screen_deo_sprite;
137- deo_handlers[0x81] = controller_deo_vector;
138- deo_handlers[0x91] = mouse_deo_vector;
139- deo_handlers[0xab] = filea_deo_vector;
140- deo_handlers[0xa5] = filea_deo_stat;
141- deo_handlers[0xa6] = filea_deo_delete;
142- deo_handlers[0xa9] = filea_deo_name;
143- deo_handlers[0xad] = filea_deo_read;
144- deo_handlers[0xaf] = filea_deo_write;
145- deo_handlers[0xbb] = filea_deo_vector;
146- deo_handlers[0xb5] = filea_deo_stat;
147- deo_handlers[0xb6] = filea_deo_delete;
148- deo_handlers[0xb9] = filea_deo_name;
149- deo_handlers[0xbd] = filea_deo_read;
150- deo_handlers[0xbf] = filea_deo_write;
151-}
152+#define CONINBUFSIZE 256
153
154 Uint8
155 emu_dei(const Uint8 port)
156@@ -1336,7 +1332,6 @@ int
157 main(int argc, char **argv)
158 {
159 int i = 1;
160- emu_connect();
161 if(argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v')
162 return !fprintf(stdout, "%s - Varvara Emulator, 8 Jan 2026.\n", argv[0]);
163 else if(argc == 1)