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:
parent
344faceb7d
commit
5ef6a7a98a
12
build.sh
12
build.sh
|
@ -31,14 +31,18 @@ cc -DNDEBUG -Os -g0 -s src/uxnasm.c -o bin/uxnasm
|
||||||
if [ "${1}" = '--install' ];
|
if [ "${1}" = '--install' ];
|
||||||
then
|
then
|
||||||
echo "Installing.."
|
echo "Installing.."
|
||||||
gcc ${RELEASE_FLAGS} ${EMU_INC}
|
gcc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${EMU_INC}
|
||||||
gcc ${RELEASE_FLAGS} ${CLI_INC}
|
gcc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${CLI_INC}
|
||||||
cp bin/uxnasm ~/bin
|
cp bin/uxnasm ~/bin
|
||||||
cp bin/uxncli ~/bin
|
cp bin/uxncli ~/bin
|
||||||
cp bin/uxn11 ~/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
|
else
|
||||||
gcc ${DEBUG_FLAGS} ${EMU_INC}
|
gcc ${C_FLAGS} ${LD_FLAGS} ${DEBUG_FLAGS} ${EMU_INC}
|
||||||
gcc ${DEBUG_FLAGS} ${CLI_INC}
|
gcc ${C_FLAGS} ${LD_FLAGS} ${DEBUG_FLAGS} ${CLI_INC}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Assembling.."
|
echo "Assembling.."
|
||||||
|
|
20
src/uxn11.c
20
src/uxn11.c
|
@ -37,6 +37,7 @@ char *rom_path;
|
||||||
#define WIDTH (64 * 8)
|
#define WIDTH (64 * 8)
|
||||||
#define HEIGHT (40 * 8)
|
#define HEIGHT (40 * 8)
|
||||||
#define PAD 4
|
#define PAD 4
|
||||||
|
#define CONINBUFSIZE 256
|
||||||
|
|
||||||
static int
|
static int
|
||||||
emu_error(char *msg, const char *err)
|
emu_error(char *msg, const char *err)
|
||||||
|
@ -225,9 +226,10 @@ int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
Uxn u;
|
Uxn u;
|
||||||
int i;
|
int i,n;
|
||||||
char expirations[8];
|
char expirations[8];
|
||||||
struct pollfd fds[2];
|
char coninp[CONINBUFSIZE];
|
||||||
|
struct pollfd fds[3];
|
||||||
static const struct itimerspec screen_tspec = {{0, 16666666}, {0, 16666666}};
|
static const struct itimerspec screen_tspec = {{0, 16666666}, {0, 16666666}};
|
||||||
if(argc < 2)
|
if(argc < 2)
|
||||||
return emu_error("Usage", "uxn11 game.rom args");
|
return emu_error("Usage", "uxn11 game.rom args");
|
||||||
|
@ -249,10 +251,11 @@ main(int argc, char **argv)
|
||||||
fds[0].fd = XConnectionNumber(display);
|
fds[0].fd = XConnectionNumber(display);
|
||||||
fds[1].fd = timerfd_create(CLOCK_MONOTONIC, 0);
|
fds[1].fd = timerfd_create(CLOCK_MONOTONIC, 0);
|
||||||
timerfd_settime(fds[1].fd, 0, &screen_tspec, NULL);
|
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 */
|
/* main loop */
|
||||||
while(!u.dev[0x0f]) {
|
while(!u.dev[0x0f]) {
|
||||||
if(poll(fds, 2, 1000) <= 0)
|
if(poll(fds, 3, 1000) <= 0)
|
||||||
continue;
|
continue;
|
||||||
while(XPending(display))
|
while(XPending(display))
|
||||||
emu_event(&u);
|
emu_event(&u);
|
||||||
|
@ -260,6 +263,15 @@ main(int argc, char **argv)
|
||||||
read(fds[1].fd, expirations, 8); /* Indicate we handled the timer */
|
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 */
|
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)
|
if(uxn_screen.fg.changed || uxn_screen.bg.changed)
|
||||||
emu_draw();
|
emu_draw();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue