Browse code

Split uxn_halt into beginnings of System device file.

Andrew Alderwick authored on 05/01/2022 12:59:22
Showing 4 changed files
... ...
@@ -14,6 +14,7 @@ then
14 14
 	echo "Formatting.."
15 15
 	clang-format -i src/uxn.h
16 16
 	clang-format -i src/uxn.c
17
+	clang-format -i src/devices/system.c
17 18
 	clang-format -i src/devices/screen.h
18 19
 	clang-format -i src/devices/screen.c
19 20
 	clang-format -i src/devices/audio.h
... ...
@@ -62,8 +63,8 @@ fi
62 63
 
63 64
 echo "Building.."
64 65
 ${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm
65
-${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
66
-${CC} ${CFLAGS} ${CORE} src/devices/file.c src/uxncli.c -o bin/uxncli
66
+${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
67
+${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/uxncli.c -o bin/uxncli
67 68
 
68 69
 if [ -d "$HOME/bin" ]
69 70
 then
70 71
new file mode 100644
... ...
@@ -0,0 +1,23 @@
1
+#include "../uxn.h"
2
+
3
+#include <stdio.h>
4
+
5
+/*
6
+Copyright (c) 2022 Devine Lu Linvega, Andrew Alderwick
7
+
8
+Permission to use, copy, modify, and distribute this software for any
9
+purpose with or without fee is hereby granted, provided that the above
10
+copyright notice and this permission notice appear in all copies.
11
+
12
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13
+WITH REGARD TO THIS SOFTWARE.
14
+*/
15
+
16
+static const char *errors[] = {"underflow", "overflow", "division by zero"};
17
+
18
+int
19
+uxn_halt(Uxn *u, Uint8 error, char *name, Uint16 addr)
20
+{
21
+	fprintf(stderr, "Halted: %s %s#%04x, at 0x%04x\n", name, errors[error - 1], u->ram[addr], addr);
22
+	return 0;
23
+}
... ...
@@ -115,15 +115,6 @@ nil_deo(Device *d, Uint8 port)
115 115
 
116 116
 #pragma mark - Generics
117 117
 
118
-static const char *errors[] = {"underflow", "overflow", "division by zero"};
119
-
120
-int
121
-uxn_halt(Uxn *u, Uint8 error, char *name, Uint16 addr)
122
-{
123
-	fprintf(stderr, "Halted: %s %s#%04x, at 0x%04x\n", name, errors[error - 1], u->ram[addr], addr);
124
-	return 0;
125
-}
126
-
127 118
 static int
128 119
 console_input(Uxn *u, char c)
129 120
 {
... ...
@@ -410,15 +410,6 @@ do_shortcut(Uxn *u, SDL_Event *event)
410 410
 		restart(u);
411 411
 }
412 412
 
413
-static const char *errors[] = {"underflow", "overflow", "division by zero"};
414
-
415
-int
416
-uxn_halt(Uxn *u, Uint8 error, char *name, Uint16 addr)
417
-{
418
-	fprintf(stderr, "Halted: %s %s#%04x, at 0x%04x\n", name, errors[error - 1], u->ram[addr], addr);
419
-	return 0;
420
-}
421
-
422 413
 static int
423 414
 console_input(Uxn *u, char c)
424 415
 {