commit e7721ab

Devine Lu Linvega  ·  2025-01-22 04:16:31 +0000 UTC
parent 6af79f6
(file.c) Cleanup
1 files changed,  +12, -18
+12, -18
 1@@ -172,8 +172,10 @@ file_check_sandbox(UxnFile *c)
 2 }
 3 
 4 static Uint16
 5-file_init(UxnFile *c, char *filename, size_t max_len, int override_sandbox)
 6+file_init(UxnFile *c, Uint16 addr, int override_sandbox)
 7 {
 8+	size_t max_len = 0x10000 - addr;
 9+	char *filename = (char *)&uxn.ram[addr];
10 	char *p = c->current_filename;
11 	size_t len = sizeof(c->current_filename);
12 	file_reset(c);
13@@ -320,11 +322,10 @@ static int rL1, rL2;
14 void
15 file_deo(Uint8 port)
16 {
17-	Uint16 addr, len, res;
18+	Uint16 res;
19 	switch(port) {
20 	case 0xa5:
21-		addr = PEEK2(&uxn.dev[0xa4]);
22-		res = file_stat(&uxn_file[0], addr, rL1);
23+		res = file_stat(&uxn_file[0], PEEK2(&uxn.dev[0xa4]), rL1);
24 		POKE2(&uxn.dev[0xa2], res);
25 		break;
26 	case 0xa6:
27@@ -332,27 +333,23 @@ file_deo(Uint8 port)
28 		POKE2(&uxn.dev[0xa2], res);
29 		break;
30 	case 0xa9:
31-		addr = PEEK2(&uxn.dev[0xa8]);
32-		res = file_init(&uxn_file[0], (char *)&uxn.ram[addr], 0x10000 - addr, 0);
33+		res = file_init(&uxn_file[0], PEEK2(&uxn.dev[0xa8]), 0);
34 		POKE2(&uxn.dev[0xa2], res);
35 		break;
36 	case 0xab:
37 		rL1 = PEEK2(&uxn.dev[0xaa]);
38 		break;
39 	case 0xad:
40-		addr = PEEK2(&uxn.dev[0xac]);
41-		res = file_read(&uxn_file[0], addr, rL1);
42+		res = file_read(&uxn_file[0], PEEK2(&uxn.dev[0xac]), rL1);
43 		POKE2(&uxn.dev[0xa2], res);
44 		break;
45 	case 0xaf:
46-		addr = PEEK2(&uxn.dev[0xae]);
47-		res = file_write(&uxn_file[0], addr, rL1, uxn.dev[0xa7]);
48+		res = file_write(&uxn_file[0], PEEK2(&uxn.dev[0xae]), rL1, uxn.dev[0xa7]);
49 		POKE2(&uxn.dev[0xa2], res);
50 		break;
51 	/* File 2 */
52 	case 0xb5:
53-		addr = PEEK2(&uxn.dev[0xb4]);
54-		res = file_stat(&uxn_file[1], addr, rL2);
55+		res = file_stat(&uxn_file[1], PEEK2(&uxn.dev[0xb4]), rL2);
56 		POKE2(&uxn.dev[0xb2], res);
57 		break;
58 	case 0xb6:
59@@ -360,21 +357,18 @@ file_deo(Uint8 port)
60 		POKE2(&uxn.dev[0xb2], res);
61 		break;
62 	case 0xb9:
63-		addr = PEEK2(&uxn.dev[0xb8]);
64-		res = file_init(&uxn_file[1], (char *)&uxn.ram[addr], 0x10000 - addr, 0);
65+		res = file_init(&uxn_file[1], PEEK2(&uxn.dev[0xb8]), 0);
66 		POKE2(&uxn.dev[0xb2], res);
67 		break;
68 	case 0xbb:
69 		rL2 = PEEK2(&uxn.dev[0xba]);
70 		break;
71 	case 0xbd:
72-		addr = PEEK2(&uxn.dev[0xbc]);
73-		res = file_read(&uxn_file[1], addr, rL2);
74+		res = file_read(&uxn_file[1], PEEK2(&uxn.dev[0xbc]), rL2);
75 		POKE2(&uxn.dev[0xb2], res);
76 		break;
77 	case 0xbf:
78-		addr = PEEK2(&uxn.dev[0xbe]);
79-		res = file_write(&uxn_file[1], addr, rL2, uxn.dev[0xb7]);
80+		res = file_write(&uxn_file[1], PEEK2(&uxn.dev[0xbe]), rL2, uxn.dev[0xb7]);
81 		POKE2(&uxn.dev[0xb2], res);
82 		break;
83 	}