Browse code

Minor cleanup

neauoire authored on 11/01/2022 19:07:25
Showing 2 changed files
... ...
@@ -1,7 +1,6 @@
1 1
 #include <stdio.h>
2 2
 #include <stdlib.h>
3 3
 #include <unistd.h>
4
-#include <time.h>
5 4
 
6 5
 #include "uxn.h"
7 6
 
... ...
@@ -63,8 +62,12 @@ system_deo_special(Device *d, Uint8 port)
63 62
 static void
64 63
 console_deo(Device *d, Uint8 port)
65 64
 {
66
-	if(port > 0x7)
67
-		write(port - 0x7, (char *)&d->dat[port], 1);
65
+	FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr
66
+												  : 0;
67
+	if(fd) {
68
+		fputc(d->dat[port], fd);
69
+		fflush(fd);
70
+	}
68 71
 }
69 72
 
70 73
 static Uint8
... ...
@@ -92,12 +95,9 @@ console_input(Uxn *u, char c)
92 95
 static void
93 96
 run(Uxn *u)
94 97
 {
95
-	Uint16 vec;
96 98
 	Device *d = devconsole;
97
-	while((!u->dev[0].dat[0xf]) && (read(0, &devconsole->dat[0x2], 1) > 0)) {
98
-		DEVPEEK16(vec, 0);
99
-		uxn_eval(u, vec);
100
-	}
99
+	while((!u->dev[0].dat[0xf]) && (read(0, &d->dat[0x2], 1) > 0))
100
+		uxn_eval(u, GETVECTOR(d));
101 101
 }
102 102
 
103 103
 static int
... ...
@@ -434,9 +434,7 @@ run(Uxn *u)
434 434
 			/* Audio */
435 435
 			else if(event.type >= audio0_event && event.type < audio0_event + POLYPHONY) {
436 436
 				Device *d = devaudio0 + (event.type - audio0_event);
437
-				Uint16 res;
438
-				DEVPEEK16(res, 0x00);
439
-				uxn_eval(u, res);
437
+				uxn_eval(u, GETVECTOR(d));
440 438
 			}
441 439
 			/* Mouse */
442 440
 			else if(event.type == SDL_MOUSEMOTION)