Split uxn_halt into beginnings of System device file.

This commit is contained in:
Andrew Alderwick 2022-01-05 12:59:22 +00:00
parent c827fdc960
commit c37831749f
4 changed files with 26 additions and 20 deletions

View File

@ -14,6 +14,7 @@ then
echo "Formatting.." echo "Formatting.."
clang-format -i src/uxn.h clang-format -i src/uxn.h
clang-format -i src/uxn.c 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.h
clang-format -i src/devices/screen.c clang-format -i src/devices/screen.c
clang-format -i src/devices/audio.h clang-format -i src/devices/audio.h
@ -62,8 +63,8 @@ fi
echo "Building.." echo "Building.."
${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm ${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/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/file.c src/uxncli.c -o bin/uxncli ${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/uxncli.c -o bin/uxncli
if [ -d "$HOME/bin" ] if [ -d "$HOME/bin" ]
then then

23
src/devices/system.c Normal file
View File

@ -0,0 +1,23 @@
#include "../uxn.h"
#include <stdio.h>
/*
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;
}

View File

@ -115,15 +115,6 @@ nil_deo(Device *d, Uint8 port)
#pragma mark - Generics #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 static int
console_input(Uxn *u, char c) console_input(Uxn *u, char c)
{ {

View File

@ -410,15 +410,6 @@ do_shortcut(Uxn *u, SDL_Event *event)
restart(u); 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 static int
console_input(Uxn *u, char c) console_input(Uxn *u, char c)
{ {