commit 96132ae
Devine Lu Linvega
·
2025-05-12 23:26:32 +0000 UTC
parent a70c2b7
(uxncli) Move more things into deo
1 files changed,
+27,
-42
+27,
-42
1@@ -181,45 +181,28 @@ system_dei(Uint8 addr)
2 }
3
4 static void
5-system_deo(Uint8 port)
6-{
7- switch(port) {
8- case 0x3: {
9- Uint16 value;
10- Uint16 addr = PEEK2(uxn.dev + 2);
11- Uint8 *aptr = uxn.ram + addr;
12- Uint16 length = PEEK2(aptr + 1);
13- if(uxn.ram[addr] == 0x0) {
14- Uint32 a = PEEK2(aptr + 3) * 0x10000 + PEEK2(aptr + 5);
15- Uint32 b = a + length;
16- value = uxn.ram[addr + 7];
17- for(; a < b; uxn.ram[a++] = value);
18- } else if(uxn.ram[addr] == 0x1) {
19- Uint32 a = PEEK2(aptr + 3) * 0x10000 + PEEK2(aptr + 5);
20- Uint32 b = a + length;
21- Uint32 c = PEEK2(aptr + 7) * 0x10000 + PEEK2(aptr + 9);
22- for(; a < b; uxn.ram[c++] = uxn.ram[a++]);
23- } else if(uxn.ram[addr] == 0x2) {
24- Uint32 a = PEEK2(aptr + 3) * 0x10000 + PEEK2(aptr + 5);
25- Uint32 b = a + length;
26- Uint32 c = PEEK2(aptr + 7) * 0x10000 + PEEK2(aptr + 9);
27- Uint32 d = c + length;
28- for(; b >= a; uxn.ram[--d] = uxn.ram[--b]);
29- } else
30- fprintf(stderr, "Unknown command: %s\n", &uxn.ram[addr]);
31- break;
32- }
33- case 0x4:
34- uxn.wst.ptr = uxn.dev[4];
35- break;
36- case 0x5:
37- uxn.rst.ptr = uxn.dev[5];
38- break;
39- case 0xe:
40- system_print("WST", &uxn.wst);
41- system_print("RST", &uxn.rst);
42- break;
43- }
44+system_expansion(Uint16 addr)
45+{
46+ Uint8 *aptr = uxn.ram + addr;
47+ Uint16 value, length = PEEK2(aptr + 1);
48+ if(uxn.ram[addr] == 0x0) {
49+ Uint32 a = PEEK2(aptr + 3) * 0x10000 + PEEK2(aptr + 5);
50+ Uint32 b = a + length;
51+ value = uxn.ram[addr + 7];
52+ for(; a < b; uxn.ram[a++] = value);
53+ } else if(uxn.ram[addr] == 0x1) {
54+ Uint32 a = PEEK2(aptr + 3) * 0x10000 + PEEK2(aptr + 5);
55+ Uint32 b = a + length;
56+ Uint32 c = PEEK2(aptr + 7) * 0x10000 + PEEK2(aptr + 9);
57+ for(; a < b; uxn.ram[c++] = uxn.ram[a++]);
58+ } else if(uxn.ram[addr] == 0x2) {
59+ Uint32 a = PEEK2(aptr + 3) * 0x10000 + PEEK2(aptr + 5);
60+ Uint32 b = a + length;
61+ Uint32 c = PEEK2(aptr + 7) * 0x10000 + PEEK2(aptr + 9);
62+ Uint32 d = c + length;
63+ for(; b >= a; uxn.ram[--d] = uxn.ram[--b]);
64+ } else
65+ fprintf(stderr, "Unknown command: %s\n", &uxn.ram[addr]);
66 }
67
68 /*
69@@ -703,10 +686,12 @@ void
70 emu_deo(Uint8 addr, Uint8 value)
71 {
72 uxn.dev[addr] = value;
73- switch(addr & 0xf0) {
74- case 0x00: system_deo(addr); break;
75- }
76 switch(addr) {
77+ /* System */
78+ case 0x03: system_expansion(PEEK2(uxn.dev + 2)); break;
79+ case 0x04: uxn.wst.ptr = uxn.dev[4]; break;
80+ case 0x05: uxn.rst.ptr = uxn.dev[5]; break;
81+ case 0x0e: system_print("WST", &uxn.wst), system_print("RST", &uxn.rst); break;
82 /* Console */
83 case 0x11: console_vector = PEEK2(&uxn.dev[0x10]); return;
84 case 0x18: fputc(uxn.dev[0x18], stdout), fflush(stdout); break;