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.

This commit is contained in:
Deadly Headshot 2023-03-18 18:04:50 +00:00 committed by Devine Lu Linvega
parent 344faceb7d
commit 5ef6a7a98a
2 changed files with 24 additions and 8 deletions

View File

@ -31,14 +31,18 @@ cc -DNDEBUG -Os -g0 -s src/uxnasm.c -o bin/uxnasm
if [ "${1}" = '--install' ];
then
echo "Installing.."
gcc ${RELEASE_FLAGS} ${EMU_INC}
gcc ${RELEASE_FLAGS} ${CLI_INC}
gcc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${EMU_INC}
gcc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${CLI_INC}
cp bin/uxnasm ~/bin
cp bin/uxncli ~/bin
cp bin/uxn11 ~/bin
elif [ "${1}" = '--release' ];
then
gcc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${EMU_INC}
gcc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${CLI_INC}
else
gcc ${DEBUG_FLAGS} ${EMU_INC}
gcc ${DEBUG_FLAGS} ${CLI_INC}
gcc ${C_FLAGS} ${LD_FLAGS} ${DEBUG_FLAGS} ${EMU_INC}
gcc ${C_FLAGS} ${LD_FLAGS} ${DEBUG_FLAGS} ${CLI_INC}
fi
echo "Assembling.."

View File

@ -37,6 +37,7 @@ char *rom_path;
#define WIDTH (64 * 8)
#define HEIGHT (40 * 8)
#define PAD 4
#define CONINBUFSIZE 256
static int
emu_error(char *msg, const char *err)
@ -225,9 +226,10 @@ int
main(int argc, char **argv)
{
Uxn u;
int i;
int i,n;
char expirations[8];
struct pollfd fds[2];
char coninp[CONINBUFSIZE];
struct pollfd fds[3];
static const struct itimerspec screen_tspec = {{0, 16666666}, {0, 16666666}};
if(argc < 2)
return emu_error("Usage", "uxn11 game.rom args");
@ -249,10 +251,11 @@ main(int argc, char **argv)
fds[0].fd = XConnectionNumber(display);
fds[1].fd = timerfd_create(CLOCK_MONOTONIC, 0);
timerfd_settime(fds[1].fd, 0, &screen_tspec, NULL);
fds[0].events = fds[1].events = POLLIN;
fds[2].fd = STDIN_FILENO;
fds[0].events = fds[1].events = fds[2].events = POLLIN;
/* main loop */
while(!u.dev[0x0f]) {
if(poll(fds, 2, 1000) <= 0)
if(poll(fds, 3, 1000) <= 0)
continue;
while(XPending(display))
emu_event(&u);
@ -260,6 +263,15 @@ main(int argc, char **argv)
read(fds[1].fd, expirations, 8); /* Indicate we handled the timer */
uxn_eval(&u, GETVEC(&u.dev[0x20])); /* Call the vector once, even if the timer fired multiple times */
}
if ((fds[2].revents & POLLIN)!=0)
{
n = read(fds[2].fd, coninp, CONINBUFSIZE-1);
coninp[n] = 0;
for (i=0;i<n;i++)
{
console_input(&u, coninp[i]);
}
}
if(uxn_screen.fg.changed || uxn_screen.bg.changed)
emu_draw();
}