commit 5ef6a7a
Deadly Headshot
·
2023-03-18 18:04:50 +0000 UTC
parent 344face
Added console input to uxn11 and added to buildscript the ability to build the release without installing using --release. Also added default flag variables to buildscript.
2 files changed,
+24,
-8
M
build.sh
M
build.sh
+8,
-4
1@@ -31,14 +31,18 @@ cc -DNDEBUG -Os -g0 -s src/uxnasm.c -o bin/uxnasm
2 if [ "${1}" = '--install' ];
3 then
4 echo "Installing.."
5- gcc ${RELEASE_FLAGS} ${EMU_INC}
6- gcc ${RELEASE_FLAGS} ${CLI_INC}
7+ gcc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${EMU_INC}
8+ gcc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${CLI_INC}
9 cp bin/uxnasm ~/bin
10 cp bin/uxncli ~/bin
11 cp bin/uxn11 ~/bin
12+elif [ "${1}" = '--release' ];
13+then
14+ gcc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${EMU_INC}
15+ gcc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${CLI_INC}
16 else
17- gcc ${DEBUG_FLAGS} ${EMU_INC}
18- gcc ${DEBUG_FLAGS} ${CLI_INC}
19+ gcc ${C_FLAGS} ${LD_FLAGS} ${DEBUG_FLAGS} ${EMU_INC}
20+ gcc ${C_FLAGS} ${LD_FLAGS} ${DEBUG_FLAGS} ${CLI_INC}
21 fi
22
23 echo "Assembling.."
+16,
-4
1@@ -37,6 +37,7 @@ char *rom_path;
2 #define WIDTH (64 * 8)
3 #define HEIGHT (40 * 8)
4 #define PAD 4
5+#define CONINBUFSIZE 256
6
7 static int
8 emu_error(char *msg, const char *err)
9@@ -225,9 +226,10 @@ int
10 main(int argc, char **argv)
11 {
12 Uxn u;
13- int i;
14+ int i,n;
15 char expirations[8];
16- struct pollfd fds[2];
17+ char coninp[CONINBUFSIZE];
18+ struct pollfd fds[3];
19 static const struct itimerspec screen_tspec = {{0, 16666666}, {0, 16666666}};
20 if(argc < 2)
21 return emu_error("Usage", "uxn11 game.rom args");
22@@ -249,10 +251,11 @@ main(int argc, char **argv)
23 fds[0].fd = XConnectionNumber(display);
24 fds[1].fd = timerfd_create(CLOCK_MONOTONIC, 0);
25 timerfd_settime(fds[1].fd, 0, &screen_tspec, NULL);
26- fds[0].events = fds[1].events = POLLIN;
27+ fds[2].fd = STDIN_FILENO;
28+ fds[0].events = fds[1].events = fds[2].events = POLLIN;
29 /* main loop */
30 while(!u.dev[0x0f]) {
31- if(poll(fds, 2, 1000) <= 0)
32+ if(poll(fds, 3, 1000) <= 0)
33 continue;
34 while(XPending(display))
35 emu_event(&u);
36@@ -260,6 +263,15 @@ main(int argc, char **argv)
37 read(fds[1].fd, expirations, 8); /* Indicate we handled the timer */
38 uxn_eval(&u, GETVEC(&u.dev[0x20])); /* Call the vector once, even if the timer fired multiple times */
39 }
40+ if ((fds[2].revents & POLLIN)!=0)
41+ {
42+ n = read(fds[2].fd, coninp, CONINBUFSIZE-1);
43+ coninp[n] = 0;
44+ for (i=0;i<n;i++)
45+ {
46+ console_input(&u, coninp[i]);
47+ }
48+ }
49 if(uxn_screen.fg.changed || uxn_screen.bg.changed)
50 emu_draw();
51 }