uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 42dea5b9145f99333300ecf8a46a180d3e71871f
parent 0b75afc41522a275b42c5933d2953652bfb15308
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Mon, 28 Mar 2022 18:16:44 +0100

Replace file_i_deo and file_i_dei.

Diffstat:
Msrc/devices/file.c | 14++++++++++----
Msrc/devices/file.h | 5+++--
Msrc/uxncli.c | 16+---------------
Msrc/uxnemu.c | 16++--------------
4 files changed, 16 insertions(+), 35 deletions(-)

diff --git 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 @@ -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/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) { @@ -122,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); diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -43,7 +43,7 @@ static SDL_Rect gRect; /* devices */ -static Device *devscreen, *devmouse, *devctrl, *devaudio0, *devfile0; +static Device *devscreen, *devmouse, *devctrl, *devaudio0; static Uint8 zoom = 1; static Uint32 stdin_event, audio0_event, redraw_event, interrupt_event; @@ -231,18 +231,6 @@ audio_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) { @@ -289,7 +277,7 @@ start(Uxn *u, char *rom) /* unused */ 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); /* datetime */ uxn_port(u, 0xc, datetime_dei, nil_deo); /* unused */ uxn_port(u, 0xd, nil_dei, nil_deo);