diff --git a/build.sh b/build.sh index 43bd5d2..851f2ca 100755 --- a/build.sh +++ b/build.sh @@ -14,6 +14,7 @@ then echo "Formatting.." clang-format -i src/uxn.h clang-format -i src/uxn.c + clang-format -i src/devices/system.c clang-format -i src/devices/screen.h clang-format -i src/devices/screen.c clang-format -i src/devices/audio.h @@ -62,8 +63,8 @@ fi echo "Building.." ${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm -${CC} ${CFLAGS} ${CORE} src/devices/file.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu -${CC} ${CFLAGS} ${CORE} src/devices/file.c src/uxncli.c -o bin/uxncli +${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu +${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/uxncli.c -o bin/uxncli if [ -d "$HOME/bin" ] then diff --git a/src/devices/system.c b/src/devices/system.c new file mode 100644 index 0000000..3b76b5d --- /dev/null +++ b/src/devices/system.c @@ -0,0 +1,23 @@ +#include "../uxn.h" + +#include + +/* +Copyright (c) 2022 Devine Lu Linvega, Andrew Alderwick + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE. +*/ + +static const char *errors[] = {"underflow", "overflow", "division by zero"}; + +int +uxn_halt(Uxn *u, Uint8 error, char *name, Uint16 addr) +{ + fprintf(stderr, "Halted: %s %s#%04x, at 0x%04x\n", name, errors[error - 1], u->ram[addr], addr); + return 0; +} diff --git a/src/uxncli.c b/src/uxncli.c index 5b8d1dc..692ed6c 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -115,15 +115,6 @@ nil_deo(Device *d, Uint8 port) #pragma mark - Generics -static const char *errors[] = {"underflow", "overflow", "division by zero"}; - -int -uxn_halt(Uxn *u, Uint8 error, char *name, Uint16 addr) -{ - fprintf(stderr, "Halted: %s %s#%04x, at 0x%04x\n", name, errors[error - 1], u->ram[addr], addr); - return 0; -} - static int console_input(Uxn *u, char c) { diff --git a/src/uxnemu.c b/src/uxnemu.c index e7455bd..8aaba28 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -410,15 +410,6 @@ do_shortcut(Uxn *u, SDL_Event *event) restart(u); } -static const char *errors[] = {"underflow", "overflow", "division by zero"}; - -int -uxn_halt(Uxn *u, Uint8 error, char *name, Uint16 addr) -{ - fprintf(stderr, "Halted: %s %s#%04x, at 0x%04x\n", name, errors[error - 1], u->ram[addr], addr); - return 0; -} - static int console_input(Uxn *u, char c) {