commit 2074c2c

neauoire  ·  2022-03-28 17:22:23 +0000 UTC
parent 387f3c7
Replace file_i_deo and file_i_dei.
4 files changed,  +22, -35
+10, -4
 1@@ -151,12 +151,18 @@ file_delete(UxnFile *c)
 2 	return unlink(c->current_filename);
 3 }
 4 
 5+static UxnFile *
 6+file_instance(Device *d)
 7+{
 8+	return &uxn_file[d - &d->u->dev[DEV_FILE0]];
 9+}
10+
11 /* IO */
12 
13 void
14-file_i_deo(int instance, Device *d, Uint8 port)
15+file_deo(Device *d, Uint8 port)
16 {
17-	UxnFile *c = &uxn_file[instance];
18+	UxnFile *c = file_instance(d);
19 	Uint16 addr, len, res;
20 	switch(port) {
21 	case 0x5:
22@@ -196,9 +202,9 @@ file_i_deo(int instance, Device *d, Uint8 port)
23 }
24 
25 Uint8
26-file_i_dei(int instance, Device *d, Uint8 port)
27+file_dei(Device *d, Uint8 port)
28 {
29-	UxnFile *c = &uxn_file[instance];
30+	UxnFile *c = file_instance(d);
31 	Uint16 res;
32 	switch(port) {
33 	case 0xc:
+3, -2
 1@@ -11,6 +11,7 @@ WITH REGARD TO THIS SOFTWARE.
 2 */
 3 
 4 #define POLYFILEY 2
 5+#define DEV_FILE0 0xa
 6 
 7-void file_i_deo(int instance, Device *d, Uint8 port);
 8-Uint8 file_i_dei(int instance, Device *d, Uint8 port);
 9+void file_deo(Device *d, Uint8 port);
10+Uint8 file_dei(Device *d, Uint8 port);
+2, -14
 1@@ -19,7 +19,7 @@ static Display *display;
 2 static Visual *visual;
 3 static Window window;
 4 
 5-static Device *devscreen, *devctrl, *devmouse, *devfile0;
 6+static Device *devscreen, *devctrl, *devmouse;
 7 
 8 #define WIDTH 64 * 8
 9 #define HEIGHT 40 * 8
10@@ -38,18 +38,6 @@ system_deo_special(Device *d, Uint8 port)
11 		screen_palette(&uxn_screen, &d->dat[0x8]);
12 }
13 
14-static void
15-file_deo(Device *d, Uint8 port)
16-{
17-	file_i_deo(d - devfile0, d, port);
18-}
19-
20-static Uint8
21-file_dei(Device *d, Uint8 port)
22-{
23-	return file_i_dei(d - devfile0, d, port);
24-}
25-
26 static int
27 console_input(Uxn *u, char c)
28 {
29@@ -207,7 +195,7 @@ start(Uxn *u, char *rom)
30 	/* empty    */ uxn_port(u, 0x7, nil_dei, nil_deo);
31 	/* control  */ devctrl = uxn_port(u, 0x8, nil_dei, nil_deo);
32 	/* mouse    */ devmouse = uxn_port(u, 0x9, nil_dei, nil_deo);
33-	/* file0    */ devfile0 = uxn_port(u, 0xa, file_dei, file_deo);
34+	/* file0    */ uxn_port(u, 0xa, file_dei, file_deo);
35 	/* file1    */ uxn_port(u, 0xb, file_dei, file_deo);
36 	/* empty    */ uxn_port(u, 0xc, datetime_dei, nil_deo);
37 	/* empty    */ uxn_port(u, 0xd, nil_dei, nil_deo);
+7, -15
 1@@ -17,8 +17,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 2 WITH REGARD TO THIS SOFTWARE.
 3 */
 4 
 5-static Device *devfile0;
 6-
 7 static int
 8 error(char *msg, const char *err)
 9 {
10@@ -44,18 +42,6 @@ console_deo(Device *d, Uint8 port)
11 	}
12 }
13 
14-static void
15-file_deo(Device *d, Uint8 port)
16-{
17-	file_i_deo(d - devfile0, d, port);
18-}
19-
20-static Uint8
21-file_dei(Device *d, Uint8 port)
22-{
23-	return file_i_dei(d - devfile0, d, port);
24-}
25-
26 static Uint8
27 nil_dei(Device *d, Uint8 port)
28 {
29@@ -101,6 +87,12 @@ load(Uxn *u, char *filepath)
30 	return 1;
31 }
32 
33+int
34+uxn_interrupt(void)
35+{
36+	return 1;
37+}
38+
39 static int
40 start(Uxn *u)
41 {
42@@ -116,7 +108,7 @@ start(Uxn *u)
43 	/* empty    */ uxn_port(u, 0x7, nil_dei, nil_deo);
44 	/* empty    */ uxn_port(u, 0x8, nil_dei, nil_deo);
45 	/* empty    */ uxn_port(u, 0x9, nil_dei, nil_deo);
46-	/* file0    */ devfile0 = uxn_port(u, 0xa, file_dei, file_deo);
47+	/* file0    */ uxn_port(u, 0xa, file_dei, file_deo);
48 	/* file1    */ uxn_port(u, 0xb, file_dei, file_deo);
49 	/* datetime */ uxn_port(u, 0xc, datetime_dei, nil_deo);
50 	/* empty    */ uxn_port(u, 0xd, nil_dei, nil_deo);