From 387f3c7e21120a89b5787ce79c61cafa9d5c9561 Mon Sep 17 00:00:00 2001 From: neauoire Date: Mon, 28 Mar 2022 09:51:38 -0700 Subject: [PATCH] Completed file implementation --- README.md | 6 +++--- src/uxn11.c | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index be25be5..fa5abf4 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,12 @@ cc src/devices/datetime.c src/devices/system.c src/devices/file.c src/uxn.c -DND - `00` system - `10` console(partial) -- `20` screen(partial/vector) +- `20` screen - `30` audio(missing) - `70` midi(missing) - `80` controller -- `90` mouse(partial/scroll) -- `a0` file(missing) +- `90` mouse(partial) +- `a0` file - `c0` datetime ## Contributing diff --git a/src/uxn11.c b/src/uxn11.c index f377fb3..0b8f852 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; +static Device *devscreen, *devctrl, *devmouse, *devfile0; #define WIDTH 64 * 8 #define HEIGHT 40 * 8 @@ -38,6 +38,18 @@ 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) { @@ -195,8 +207,8 @@ 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); - /* file */ uxn_port(u, 0xa, nil_dei, nil_deo); - /* datetime */ uxn_port(u, 0xb, nil_dei, nil_deo); + /* file0 */ devfile0 = 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); /* empty */ uxn_port(u, 0xe, nil_dei, nil_deo);