commit ed24273
Devine Lu Linvega
·
2024-07-01 15:46:22 +0000 UTC
parent b3fcbe9
Removed file ID passing to file_deo
4 files changed,
+62,
-30
+57,
-25
1@@ -245,44 +245,76 @@ file_delete(UxnFile *c)
2 /* IO */
3
4 void
5-file_deo(Uint8 id, Uint8 port)
6+file_deo(Uint8 port)
7 {
8- UxnFile *c = &uxn_file[id];
9 Uint16 addr, len, res;
10- Uint8 *d = id ? &uxn.dev[0xb0] : &uxn.dev[0xa0];
11 switch(port) {
12- case 0x5:
13- addr = PEEK2(d + 0x4);
14- len = PEEK2(d + 0xa);
15+ case 0xa5:
16+ addr = PEEK2(&uxn.dev[0xa4]);
17+ len = PEEK2(&uxn.dev[0xaa]);
18 if(len > 0x10000 - addr)
19 len = 0x10000 - addr;
20- res = file_stat(c, &uxn.ram[addr], len);
21- POKE2(d + 0x2, res);
22+ res = file_stat(&uxn_file[0], &uxn.ram[addr], len);
23+ POKE2(&uxn.dev[0xa2], res);
24 break;
25- case 0x6:
26- res = file_delete(c);
27- POKE2(d + 0x2, res);
28+ case 0xa6:
29+ res = file_delete(&uxn_file[0]);
30+ POKE2(&uxn.dev[0xa2], res);
31 break;
32- case 0x9:
33- addr = PEEK2(d + 0x8);
34- res = file_init(c, (char *)&uxn.ram[addr], 0x10000 - addr, 0);
35- POKE2(d + 0x2, res);
36+ case 0xa9:
37+ addr = PEEK2(&uxn.dev[0xa8]);
38+ res = file_init(&uxn_file[0], (char *)&uxn.ram[addr], 0x10000 - addr, 0);
39+ POKE2(&uxn.dev[0xa2], res);
40 break;
41- case 0xd:
42- addr = PEEK2(d + 0xc);
43- len = PEEK2(d + 0xa);
44+ case 0xad:
45+ addr = PEEK2(&uxn.dev[0xac]);
46+ len = PEEK2(&uxn.dev[0xaa]);
47 if(len > 0x10000 - addr)
48 len = 0x10000 - addr;
49- res = file_read(c, &uxn.ram[addr], len);
50- POKE2(d + 0x2, res);
51+ res = file_read(&uxn_file[0], &uxn.ram[addr], len);
52+ POKE2(&uxn.dev[0xa2], res);
53 break;
54- case 0xf:
55- addr = PEEK2(d + 0xe);
56- len = PEEK2(d + 0xa);
57+ case 0xaf:
58+ addr = PEEK2(&uxn.dev[0xae]);
59+ len = PEEK2(&uxn.dev[0xaa]);
60 if(len > 0x10000 - addr)
61 len = 0x10000 - addr;
62- res = file_write(c, &uxn.ram[addr], len, d[0x7]);
63- POKE2(d + 0x2, res);
64+ res = file_write(&uxn_file[0], &uxn.ram[addr], len, uxn.dev[0xa7]);
65+ POKE2(&uxn.dev[0xa2], res);
66+ break;
67+ /* File 2 */
68+ case 0xb5:
69+ addr = PEEK2(&uxn.dev[0xb4]);
70+ len = PEEK2(&uxn.dev[0xba]);
71+ if(len > 0x10000 - addr)
72+ len = 0x10000 - addr;
73+ res = file_stat(&uxn_file[1], &uxn.ram[addr], len);
74+ POKE2(&uxn.dev[0xb2], res);
75+ break;
76+ case 0xb6:
77+ res = file_delete(&uxn_file[1]);
78+ POKE2(&uxn.dev[0xb2], res);
79+ break;
80+ case 0xb9:
81+ addr = PEEK2(&uxn.dev[0xb8]);
82+ res = file_init(&uxn_file[1], (char *)&uxn.ram[addr], 0x10000 - addr, 0);
83+ POKE2(&uxn.dev[0xb2], res);
84+ break;
85+ case 0xbd:
86+ addr = PEEK2(&uxn.dev[0xbc]);
87+ len = PEEK2(&uxn.dev[0xba]);
88+ if(len > 0x10000 - addr)
89+ len = 0x10000 - addr;
90+ res = file_read(&uxn_file[1], &uxn.ram[addr], len);
91+ POKE2(&uxn.dev[0xb2], res);
92+ break;
93+ case 0xbf:
94+ addr = PEEK2(&uxn.dev[0xbe]);
95+ len = PEEK2(&uxn.dev[0xba]);
96+ if(len > 0x10000 - addr)
97+ len = 0x10000 - addr;
98+ res = file_write(&uxn_file[1], &uxn.ram[addr], len, uxn.dev[0xb7]);
99+ POKE2(&uxn.dev[0xb2], res);
100 break;
101 }
102 }
+1,
-1
1@@ -12,4 +12,4 @@ WITH REGARD TO THIS SOFTWARE.
2 #define POLYFILEY 2
3 #define DEV_FILE0 0xa
4
5-void file_deo(Uint8 id, Uint8 port);
6+void file_deo(Uint8 port);
+2,
-2
1@@ -69,8 +69,8 @@ emu_deo(Uint8 addr, Uint8 value)
2 break;
3 case 0x10: console_deo(p); break;
4 case 0x20: screen_deo(p); break;
5- case 0xa0: file_deo(0, p); break;
6- case 0xb0: file_deo(1, p); break;
7+ case 0xa0: file_deo(addr); break;
8+ case 0xb0: file_deo(addr); break;
9 }
10 }
11
+2,
-2
1@@ -39,8 +39,8 @@ emu_deo(Uint8 addr, Uint8 value)
2 switch(addr & 0xf0) {
3 case 0x00: system_deo(p); break;
4 case 0x10: console_deo(p); break;
5- case 0xa0: file_deo(0, p); break;
6- case 0xb0: file_deo(1, p); break;
7+ case 0xa0: file_deo(addr); break;
8+ case 0xb0: file_deo(addr); break;
9 }
10 }
11