diff --git a/src/devices/file.c b/src/devices/file.c index d99545f..906ac73 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -151,12 +151,18 @@ file_delete(UxnFile *c) return unlink(c->current_filename); } +static UxnFile * +file_instance(Device *d) +{ + return &uxn_file[d - &d->u->dev[DEV_FILE0]]; +} + /* IO */ void -file_i_deo(int instance, Device *d, Uint8 port) +file_deo(Device *d, Uint8 port) { - UxnFile *c = &uxn_file[instance]; + UxnFile *c = file_instance(d); Uint16 addr, len, res; switch(port) { case 0x5: @@ -196,9 +202,9 @@ file_i_deo(int instance, Device *d, Uint8 port) } Uint8 -file_i_dei(int instance, Device *d, Uint8 port) +file_dei(Device *d, Uint8 port) { - UxnFile *c = &uxn_file[instance]; + UxnFile *c = file_instance(d); Uint16 res; switch(port) { case 0xc: diff --git a/src/devices/file.h b/src/devices/file.h index 09c2cdc..9fc5b44 100644 --- a/src/devices/file.h +++ b/src/devices/file.h @@ -11,6 +11,7 @@ WITH REGARD TO THIS SOFTWARE. */ #define POLYFILEY 2 +#define DEV_FILE0 0xa -void file_i_deo(int instance, Device *d, Uint8 port); -Uint8 file_i_dei(int instance, Device *d, Uint8 port); +void file_deo(Device *d, Uint8 port); +Uint8 file_dei(Device *d, Uint8 port); diff --git a/src/uxn11.c b/src/uxn11.c index 0b8f852..334ff51 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -19,7 +19,7 @@ static Display *display; static Visual *visual; static Window window; -static Device *devscreen, *devctrl, *devmouse, *devfile0; +static Device *devscreen, *devctrl, *devmouse; #define WIDTH 64 * 8 #define HEIGHT 40 * 8 @@ -38,18 +38,6 @@ system_deo_special(Device *d, Uint8 port) screen_palette(&uxn_screen, &d->dat[0x8]); } -static void -file_deo(Device *d, Uint8 port) -{ - file_i_deo(d - devfile0, d, port); -} - -static Uint8 -file_dei(Device *d, Uint8 port) -{ - return file_i_dei(d - devfile0, d, port); -} - static int console_input(Uxn *u, char c) { @@ -207,7 +195,7 @@ start(Uxn *u, char *rom) /* empty */ uxn_port(u, 0x7, nil_dei, nil_deo); /* control */ devctrl = uxn_port(u, 0x8, nil_dei, nil_deo); /* mouse */ devmouse = uxn_port(u, 0x9, nil_dei, nil_deo); - /* file0 */ devfile0 = uxn_port(u, 0xa, file_dei, file_deo); + /* file0 */ uxn_port(u, 0xa, file_dei, file_deo); /* file1 */ uxn_port(u, 0xb, file_dei, file_deo); /* empty */ uxn_port(u, 0xc, datetime_dei, nil_deo); /* empty */ uxn_port(u, 0xd, nil_dei, nil_deo); diff --git a/src/uxncli.c b/src/uxncli.c index c6da9b2..bb3eb47 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -17,8 +17,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ -static Device *devfile0; - static int error(char *msg, const char *err) { @@ -44,18 +42,6 @@ console_deo(Device *d, Uint8 port) } } -static void -file_deo(Device *d, Uint8 port) -{ - file_i_deo(d - devfile0, d, port); -} - -static Uint8 -file_dei(Device *d, Uint8 port) -{ - return file_i_dei(d - devfile0, d, port); -} - static Uint8 nil_dei(Device *d, Uint8 port) { @@ -101,6 +87,12 @@ load(Uxn *u, char *filepath) return 1; } +int +uxn_interrupt(void) +{ + return 1; +} + static int start(Uxn *u) { @@ -116,7 +108,7 @@ start(Uxn *u) /* empty */ uxn_port(u, 0x7, nil_dei, nil_deo); /* empty */ uxn_port(u, 0x8, nil_dei, nil_deo); /* empty */ uxn_port(u, 0x9, nil_dei, nil_deo); - /* file0 */ devfile0 = uxn_port(u, 0xa, file_dei, file_deo); + /* file0 */ uxn_port(u, 0xa, file_dei, file_deo); /* file1 */ uxn_port(u, 0xb, file_dei, file_deo); /* datetime */ uxn_port(u, 0xc, datetime_dei, nil_deo); /* empty */ uxn_port(u, 0xd, nil_dei, nil_deo);