From f494421979d1c20a636a9425dba3db3a6bf4024d Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 26 Mar 2022 20:20:29 -0700 Subject: [PATCH] Implemented controller --- etc/controller.rom | Bin 868 -> 896 bytes etc/move.rom | Bin 0 -> 311 bytes src/uxn11.c | 32 ++++++++++++++++---------------- 3 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 etc/move.rom diff --git a/etc/controller.rom b/etc/controller.rom index be2836e41b60180f2674111fbc15866e6ded7f2f..aad7cde56506ddbfec414ac2f66067559b82cabc 100644 GIT binary patch delta 184 zcmaFD*1$fYOgKfaL4c2;frqc5$!r0$yWRpWiHTh@j29*@mt(v!@t6kVgNg6u7+*~0 zW0Ye&FtNeRLT}GwJvP_DqEDRPPqx8jdSQ{Alm>XE+fm8#(408h~SA)8gM1z4u LgT!VxCOJj`wI4JI delta 156 zcmZo*f5JAQOvFR4L6DE3ftRnLNvwf`gNI=OBj3bM8OALWm&q~inRrx#@yNt?a*Sst z^D@dYu9>XED9dx;`)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 literal 0 HcmV?d00001 diff --git a/src/uxn11.c b/src/uxn11.c index 5e8d1f1..b02f2ac 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -67,6 +67,16 @@ load(Uxn *u, char *filepath) return 1; } +void +redraw(Display *display, Visual *visual, Window window) +{ + XImage *ximage; + screen_redraw(&uxn_screen, uxn_screen.pixels); + ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width, uxn_screen.height, 32, 0); + XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, 0, 0, uxn_screen.width, uxn_screen.height); + /* XDestroyImage(ximage); */ +} + /* /usr/include/X11/keysymdef.h */ #define XK_Left 0xff51 @@ -80,13 +90,13 @@ load(Uxn *u, char *filepath) #define XK_Alt 0xffe9 void -processEvent(Display *display, Window window, XImage *ximage, int width, int height) +processEvent(Display *display, Visual *visual, Window window) { XEvent ev; XNextEvent(display, &ev); switch(ev.type) { case Expose: - XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, 0, 0, width, height); + redraw(display, visual, window); break; case KeyPress: { XKeyPressedEvent *e = (XKeyPressedEvent *)&ev; @@ -113,6 +123,9 @@ processEvent(Display *display, Window window, XImage *ximage, int width, int hei case ButtonPress: exit(0); } + if(uxn_screen.fg.changed || uxn_screen.bg.changed) { + redraw(display, visual, window); + } } static int @@ -139,11 +152,6 @@ start(Uxn *u) return 1; } -void -redraw(void) -{ -} - int main(int argc, char **argv) { @@ -161,9 +169,6 @@ main(int argc, char **argv) if(!uxn_eval(&u, PAGE_PROGRAM)) return error("Boot", "Failed to start rom."); - screen_redraw(&uxn_screen, uxn_screen.pixels); - - XImage *ximage; Display *display = XOpenDisplay(NULL); Visual *visual = DefaultVisual(display, 0); Window window = XCreateSimpleWindow(display, RootWindow(display, 0), 0, 0, uxn_screen.width, uxn_screen.height, 1, 0, 0); @@ -172,15 +177,10 @@ main(int argc, char **argv) exit(1); } - ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width, uxn_screen.height, 32, 0); - XSelectInput(display, window, ButtonPressMask | ExposureMask | KeyPressMask | KeyReleaseMask); XMapWindow(display, window); while(1) { - processEvent(display, window, ximage, uxn_screen.width, uxn_screen.height); - - if(uxn_screen.fg.changed || uxn_screen.bg.changed) - redraw(); + processEvent(display, visual, window); } return 0; } \ No newline at end of file