Browse code

Standardized main() in uxncli and uxnemu

neauoire authored on 16/08/2023 01:47:34
Showing 2 changed files
... ...
@@ -41,7 +41,17 @@ emu_deo(Uxn *u, Uint8 addr)
41 41
 	}
42 42
 }
43 43
 
44
-int
44
+static void
45
+emu_run(Uxn *u)
46
+{
47
+	while(!u->dev[0x0f]) {
48
+		int c = fgetc(stdin);
49
+		if(c == EOF) break;
50
+		console_input(u, (Uint8)c, CONSOLE_STD);
51
+	}
52
+}
53
+
54
+static int
45 55
 emu_end(Uxn *u)
46 56
 {
47 57
 	free(u->ram);
... ...
@@ -70,11 +80,7 @@ main(int argc, char **argv)
70 80
 	u.dev[0x17] = argc - i;
71 81
 	if(uxn_eval(&u, PAGE_PROGRAM)) {
72 82
 		console_listen(&u, i, argc, argv);
73
-		while(!u.dev[0x0f]) {
74
-			int c = fgetc(stdin);
75
-			if(c == EOF) break;
76
-			console_input(&u, (Uint8)c, CONSOLE_STD);
77
-		}
83
+		emu_run(&u);
78 84
 	}
79 85
 	return emu_end(&u);
80 86
 }
... ...
@@ -517,7 +517,7 @@ emu_run(Uxn *u, char *rom)
517 517
 	}
518 518
 }
519 519
 
520
-int
520
+static int
521 521
 emu_end(Uxn *u)
522 522
 {
523 523
 #ifdef _WIN32