From c58fecb85e066410e5f5acc102992cc60103ed29 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sun, 27 Mar 2022 10:01:06 -0700 Subject: [PATCH] Started file, fixed issue with mouse --- README.md | 2 +- build.sh | 6 +++--- etc/{clock.rom => datetime.rom} | Bin etc/mouse.rom | Bin 0 -> 421 bytes etc/move.rom | Bin 311 -> 0 bytes src/devices/file.c | 12 ++++++------ src/devices/system.c | 4 ++-- src/uxn11.c | 21 +++++++++++++++++++-- 8 files changed, 31 insertions(+), 14 deletions(-) rename etc/{clock.rom => datetime.rom} (100%) create mode 100644 etc/mouse.rom delete mode 100644 etc/move.rom 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 0000000000000000000000000000000000000000..7e3b2b9f289ca50105b931bdea5e54eb8e3db10d GIT binary patch literal 421 zcmYL^!AiqG5QaBvEHNZ)EYe!=WGI9xaW?@sIYktF0Z)Pl5xnK#)!TpbDn)uym}l?_ zd;?#hkI3oWf;EypMPeERtOATbqEbTc8Cml6TBNi@(bq%p+aU5Da_b(F~dz_BXj2YD{zsMLPQ?Jx5232tKqd}Wie*Cie~upMM)WzX_io#$Aq{yJ7F jr}EvO(RG_*&;;0znN91KAgZY?vt4`E;%B+~TPETkl&yQ1 literal 0 HcmV?d00001 diff --git a/etc/move.rom b/etc/move.rom deleted file mode 100644 index 646ee0bfac943354ef97864d8945325c89b124db..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 311 zcmX|*F;2r!5JboO9ex~PLKVBPWD^iVC{l0%22t1r$FYx;`)w3O_aQtjFfJ5nGh~`*?`Y0LqwEV z;F@h>c$yJ&Mlt2xA$YK*VKGHVV{|s&&7p$-3J(>G72@WNR~1FqwZ8GiP31neugOl& zof0RBMx32cLvWcH1`)$pIBN}MZx^j_*}|qp(KJth&GWi`gipgzWDWSfABJy5=S6Cv eD9bIN=rc?`6y5h8dl{=l)p>8NnXLESwEqBclTkMS 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));