commit a70c2b7
Devine Lu Linvega
·
2025-05-12 23:18:46 +0000 UTC
parent a94ec7a
(uxncli) Removed device deo indirection
1 files changed,
+22,
-38
+22,
-38
1@@ -270,7 +270,6 @@ static pid_t child_pid;
2 #define CMD_EXIT 0x16 /* if dead, exit code of process */
3 #define CMD_ADDR 0x1c /* address to read command args from */
4 #define CMD_MODE 0x1e /* mode to execute, 0x00 to 0x07 */
5-#define CMD_EXEC 0x1f /* write to execute programs, etc */
6
7 /* call after we're sure the process has exited */
8
9@@ -422,18 +421,6 @@ console_dei(Uint8 addr)
10 return uxn.dev[addr];
11 }
12
13-static void
14-console_deo(Uint8 addr)
15-{
16- FILE *fd;
17- switch(addr) {
18- case 0x11: console_vector = PEEK2(&uxn.dev[0x10]); return;
19- case 0x18: fd = stdout, fputc(uxn.dev[0x18], fd), fflush(fd); break;
20- case 0x19: fd = stderr, fputc(uxn.dev[0x19], fd), fflush(fd); break;
21- case CMD_EXEC: start_fork(); break;
22- }
23-}
24-
25 /*
26 @|File -------------------------------------------------------------- */
27
28@@ -670,27 +657,6 @@ file_success(int port, int value)
29
30 static int rL1, rL2;
31
32-static void
33-file_deo(Uint8 port)
34-{
35- switch(port) {
36- /* File 1 */
37- case 0xab: rL1 = PEEK2(&uxn.dev[0xaa]); break;
38- case 0xa5: file_success(0xa2, file_stat(0, PEEK2(&uxn.dev[0xa4]), rL1)); break;
39- case 0xa6: file_success(0xa2, file_delete(0)); break;
40- case 0xa9: file_success(0xa2, file_init(0, PEEK2(&uxn.dev[0xa8]))); break;
41- case 0xad: file_success(0xa2, file_read(0, PEEK2(&uxn.dev[0xac]), rL1)); break;
42- case 0xaf: file_success(0xa2, file_write(0, PEEK2(&uxn.dev[0xae]), rL1, uxn.dev[0xa7])); break;
43- /* File 2 */
44- case 0xbb: rL2 = PEEK2(&uxn.dev[0xba]); break;
45- case 0xb5: file_success(0xb2, file_stat(1, PEEK2(&uxn.dev[0xb4]), rL2)); break;
46- case 0xb6: file_success(0xb2, file_delete(1)); break;
47- case 0xb9: file_success(0xb2, file_init(1, PEEK2(&uxn.dev[0xb8]))); break;
48- case 0xbd: file_success(0xb2, file_read(1, PEEK2(&uxn.dev[0xbc]), rL2)); break;
49- case 0xbf: file_success(0xb2, file_write(1, PEEK2(&uxn.dev[0xbe]), rL2, uxn.dev[0xb7])); break;
50- }
51-}
52-
53 /*
54 @|Datetime ---------------------------------------------------------- */
55
56@@ -739,9 +705,27 @@ emu_deo(Uint8 addr, Uint8 value)
57 uxn.dev[addr] = value;
58 switch(addr & 0xf0) {
59 case 0x00: system_deo(addr); break;
60- case 0x10: console_deo(addr); break;
61- case 0xa0: file_deo(addr); break;
62- case 0xb0: file_deo(addr); break;
63+ }
64+ switch(addr) {
65+ /* Console */
66+ case 0x11: console_vector = PEEK2(&uxn.dev[0x10]); return;
67+ case 0x18: fputc(uxn.dev[0x18], stdout), fflush(stdout); break;
68+ case 0x19: fputc(uxn.dev[0x19], stderr), fflush(stderr); break;
69+ case 0x1f: start_fork(); break;
70+ /* File 1 */
71+ case 0xab: rL1 = PEEK2(&uxn.dev[0xaa]); break;
72+ case 0xa5: file_success(0xa2, file_stat(0, PEEK2(&uxn.dev[0xa4]), rL1)); break;
73+ case 0xa6: file_success(0xa2, file_delete(0)); break;
74+ case 0xa9: file_success(0xa2, file_init(0, PEEK2(&uxn.dev[0xa8]))); break;
75+ case 0xad: file_success(0xa2, file_read(0, PEEK2(&uxn.dev[0xac]), rL1)); break;
76+ case 0xaf: file_success(0xa2, file_write(0, PEEK2(&uxn.dev[0xae]), rL1, uxn.dev[0xa7])); break;
77+ /* File 2 */
78+ case 0xbb: rL2 = PEEK2(&uxn.dev[0xba]); break;
79+ case 0xb5: file_success(0xb2, file_stat(1, PEEK2(&uxn.dev[0xb4]), rL2)); break;
80+ case 0xb6: file_success(0xb2, file_delete(1)); break;
81+ case 0xb9: file_success(0xb2, file_init(1, PEEK2(&uxn.dev[0xb8]))); break;
82+ case 0xbd: file_success(0xb2, file_read(1, PEEK2(&uxn.dev[0xbc]), rL2)); break;
83+ case 0xbf: file_success(0xb2, file_write(1, PEEK2(&uxn.dev[0xbe]), rL2, uxn.dev[0xb7])); break;
84 }
85 }
86
87@@ -750,7 +734,7 @@ main(int argc, char **argv)
88 {
89 int i = 1;
90 if(argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v')
91- return !fprintf(stdout, "Uxn11 - Varvara Emulator(cli), 3 May 2025.\n");
92+ return !fprintf(stdout, "Uxn11 - Varvara Emulator(cli), 12 May 2025.\n");
93 else if(argc == 1)
94 return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
95 else if(!system_boot((Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++], argc > 2))