diff --git a/README.md b/README.md index f330dc9..350ed78 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ An emulator for the [Uxn stack-machine](https://wiki.xxiivv.com/site/uxn.html), All you need is X11. ``` -gcc src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/datetime.c src/uxn11.c -DNDEBUG -Os -g0 -s -o bin/uxn11 -lX11 +gcc src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/file.c src/devices/datetime.c src/uxn11.c -DNDEBUG -Os -g0 -s -o bin/uxn11 -lX11 ``` ## Terminal diff --git a/build.sh b/build.sh index 2c89f4b..ba657f8 100755 --- a/build.sh +++ b/build.sh @@ -9,10 +9,10 @@ echo "Building.." mkdir -p bin # Build(debug) -gcc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11 +gcc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/file.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11 # Build(release) -# gcc src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11 +# gcc src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/file.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11 echo "Running.." -bin/uxn11 etc/controller.rom +bin/uxn11 etc/mouse.rom diff --git a/etc/clock.rom b/etc/datetime.rom similarity index 100% rename from etc/clock.rom rename to etc/datetime.rom diff --git a/etc/mouse.rom b/etc/mouse.rom new file mode 100644 index 0000000..7e3b2b9 Binary files /dev/null and b/etc/mouse.rom differ diff --git a/etc/move.rom b/etc/move.rom deleted file mode 100644 index 646ee0b..0000000 Binary files a/etc/move.rom and /dev/null differ diff --git a/src/devices/file.c b/src/devices/file.c index d31d88e..d99545f 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -1,3 +1,9 @@ +#include +#include +#include +#include +#include + #include "../uxn.h" #include "file.h" @@ -13,12 +19,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ -#include -#include -#include -#include -#include - typedef struct { FILE *f; DIR *dir; diff --git a/src/devices/system.c b/src/devices/system.c index 413773d..b4b301e 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -1,8 +1,8 @@ +#include + #include "../uxn.h" #include "system.h" -#include - /* Copyright (c) 2022 Devine Lu Linvega, Andrew Alderwick diff --git a/src/uxn11.c b/src/uxn11.c index 81015e7..3b5a6c9 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -7,6 +7,7 @@ #include "devices/screen.h" #include "devices/controller.h" #include "devices/mouse.h" +#include "devices/file.h" #include "devices/datetime.h" static XImage *ximage; @@ -33,6 +34,14 @@ system_deo_special(Device *d, Uint8 port) screen_palette(&uxn_screen, &d->dat[0x8]); } +static int +console_input(Uxn *u, char c) +{ + Device *d = &u->dev[1]; + d->dat[0x2] = c; + return uxn_eval(u, GETVECTOR(d)); +} + static void console_deo(Device *d, Uint8 port) { @@ -129,11 +138,11 @@ processEvent(void) } break; case ButtonPress: { XButtonPressedEvent *e = (XButtonPressedEvent *)&ev; - mouse_down(devmouse, e->button); + mouse_down(devmouse, 0x1 << e->button - 1); } break; case ButtonRelease: { XButtonPressedEvent *e = (XButtonPressedEvent *)&ev; - mouse_up(devmouse, e->button); + mouse_up(devmouse, 0x1 << e->button - 1); } break; case MotionNotify: { XMotionEvent *e = (XMotionEvent *)&ev; @@ -192,12 +201,20 @@ int main(int argc, char **argv) { Uxn u; + int i; if(argc < 2) return error("Usage", "uxncli game.rom args"); if(!start(&u, argv[1])) return error("Start", "Failed"); if(!init()) return error("Init", "Failed"); + /* console vector */ + for(i = 2; i < argc; i++) { + char *p = argv[i]; + while(*p) console_input(&u, *p++); + console_input(&u, '\n'); + } + /* main loop */ while(1) { processEvent(); uxn_eval(&u, GETVECTOR(devscreen));