commit 428184d
Devine Lu Linvega
·
2024-11-13 18:36:48 +0000 UTC
parent 76d04a2
Bios instance can call the system device
4 files changed,
+23,
-23
+17,
-17
1@@ -106,44 +106,44 @@ system_boot(Uint8 *ram, char *boot)
2 /* IO */
3
4 Uint8
5-system_dei(Uint8 addr)
6+system_dei(Uxn *u, Uint8 addr)
7 {
8 switch(addr) {
9 case 0x4: return uxn.wst.ptr;
10 case 0x5: return uxn.rst.ptr;
11- default: return uxn.dev[addr];
12+ default: return u->dev[addr];
13 }
14 }
15
16 void
17-system_deo(Uint8 port)
18+system_deo(Uxn *u, Uint8 port)
19 {
20 switch(port) {
21 case 0x3: {
22- Uint16 addr = PEEK2(uxn.dev + 2);
23- if(uxn.ram[addr] == 0x0) {
24- Uint8 value = uxn.ram[addr + 7];
25- Uint16 i, length = PEEK2(uxn.ram + addr + 1);
26- Uint16 dst_page = PEEK2(uxn.ram + addr + 3), dst_addr = PEEK2(uxn.ram + addr + 5);
27+ Uint16 addr = PEEK2(u->dev + 2);
28+ if(u->ram[addr] == 0x0) {
29+ Uint8 value = u->ram[addr + 7];
30+ Uint16 i, length = PEEK2(u->ram + addr + 1);
31+ Uint16 dst_page = PEEK2(u->ram + addr + 3), dst_addr = PEEK2(u->ram + addr + 5);
32 int dst = (dst_page % RAM_PAGES) * 0x10000;
33 for(i = 0; i < length; i++)
34 uxn.ram[dst + (Uint16)(dst_addr + i)] = value;
35- } else if(uxn.ram[addr] == 0x1) {
36- Uint16 i, length = PEEK2(uxn.ram + addr + 1);
37- Uint16 a_page = PEEK2(uxn.ram + addr + 3), a_addr = PEEK2(uxn.ram + addr + 5);
38- Uint16 b_page = PEEK2(uxn.ram + addr + 7), b_addr = PEEK2(uxn.ram + addr + 9);
39+ } else if(u->ram[addr] == 0x1) {
40+ Uint16 i, length = PEEK2(u->ram + addr + 1);
41+ Uint16 a_page = PEEK2(u->ram + addr + 3), a_addr = PEEK2(u->ram + addr + 5);
42+ Uint16 b_page = PEEK2(u->ram + addr + 7), b_addr = PEEK2(u->ram + addr + 9);
43 int src = (a_page % RAM_PAGES) * 0x10000, dst = (b_page % RAM_PAGES) * 0x10000;
44 for(i = 0; i < length; i++)
45 uxn.ram[dst + (Uint16)(b_addr + i)] = uxn.ram[src + (Uint16)(a_addr + i)];
46- } else if(uxn.ram[addr] == 0x2) {
47- Uint16 i, length = PEEK2(uxn.ram + addr + 1);
48- Uint16 a_page = PEEK2(uxn.ram + addr + 3), a_addr = PEEK2(uxn.ram + addr + 5);
49- Uint16 b_page = PEEK2(uxn.ram + addr + 7), b_addr = PEEK2(uxn.ram + addr + 9);
50+ } else if(u->ram[addr] == 0x2) {
51+ Uint16 i, length = PEEK2(u->ram + addr + 1);
52+ Uint16 a_page = PEEK2(u->ram + addr + 3), a_addr = PEEK2(u->ram + addr + 5);
53+ Uint16 b_page = PEEK2(u->ram + addr + 7), b_addr = PEEK2(u->ram + addr + 9);
54 int src = (a_page % RAM_PAGES) * 0x10000, dst = (b_page % RAM_PAGES) * 0x10000;
55 for(i = length - 1; i != 0xffff; i--)
56 uxn.ram[dst + (Uint16)(b_addr + i)] = uxn.ram[src + (Uint16)(a_addr + i)];
57 } else
58- fprintf(stderr, "Unknown Expansion Command 0x%02x\n", uxn.ram[addr]);
59+ fprintf(stderr, "Unknown Expansion Command 0x%02x\n", u->ram[addr]);
60 break;
61 }
62 case 0x4:
+2,
-2
1@@ -17,8 +17,8 @@ void system_inspect(void);
2 int system_error(char *msg, const char *err);
3 int system_boot(Uint8 *ram, char *rom);
4
5-Uint8 system_dei(Uint8 addr);
6-void system_deo(Uint8 addr);
7+Uint8 system_dei(Uxn*u,Uint8 addr);
8+void system_deo(Uxn*u,Uint8 addr);
9
10 extern char *boot_rom;
11 extern Uxn bios;
+2,
-2
1@@ -49,7 +49,7 @@ Uint8
2 emu_dei(Uxn *u, Uint8 addr)
3 {
4 switch(addr & 0xf0) {
5- case 0x00: return system_dei(addr);
6+ case 0x00: return system_dei(u, addr);
7 case 0x10: return console_dei(u, addr);
8 case 0x20: return screen_dei(u, addr);
9 case 0xc0: return datetime_dei(addr);
10@@ -63,7 +63,7 @@ emu_deo(Uxn *u, Uint8 addr, Uint8 value)
11 u->dev[addr] = value;
12 switch(addr & 0xf0) {
13 case 0x00:
14- system_deo(addr);
15+ system_deo(u, addr);
16 if(addr > 0x7 && addr < 0xe)
17 screen_palette();
18 break;
+2,
-2
1@@ -25,7 +25,7 @@ Uint8
2 emu_dei(Uxn *u, Uint8 addr)
3 {
4 switch(addr & 0xf0) {
5- case 0x00: return system_dei(addr);
6+ case 0x00: return system_dei(u, addr);
7 case 0x10: return console_dei(u, addr);
8 case 0xc0: return datetime_dei(addr);
9 }
10@@ -37,7 +37,7 @@ emu_deo(Uxn *u, Uint8 addr, Uint8 value)
11 {
12 u->dev[addr] = value;
13 switch(addr & 0xf0) {
14- case 0x00: system_deo(addr); break;
15+ case 0x00: system_deo(u, addr); break;
16 case 0x10: console_deo(u, addr); break;
17 case 0xa0: file_deo(addr); break;
18 case 0xb0: file_deo(addr); break;