Browse code

System device handles boot

neauoire authored on 15/08/2023 22:59:32
Showing 6 changed files
... ...
@@ -94,6 +94,13 @@ system_version(char *name, char *date)
94 94
 	return 0;
95 95
 }
96 96
 
97
+int
98
+system_boot(Uxn *u, Uint8 *ram)
99
+{
100
+	u->ram = ram;
101
+	return 1;
102
+}
103
+
97 104
 /* IO */
98 105
 
99 106
 void
... ...
@@ -103,13 +110,6 @@ system_deo(Uxn *u, Uint8 *d, Uint8 port)
103 110
 	case 0x3:
104 111
 		system_cmd(u->ram, PEEK2(d + 2));
105 112
 		break;
106
-	case 0x5:
107
-		if(PEEK2(d + 4)) {
108
-			Uxn friend;
109
-			uxn_boot(&friend, u->ram);
110
-			uxn_eval(&friend, PEEK2(d + 4));
111
-		}
112
-		break;
113 113
 	case 0xe:
114 114
 		system_inspect(u);
115 115
 		break;
... ...
@@ -20,4 +20,5 @@ int system_version(char *emulator, char *date);
20 20
 int system_load(Uxn *u, char *filename);
21 21
 void system_inspect(Uxn *u);
22 22
 int system_error(char *msg, const char *err);
23
+int system_boot(Uxn *u, Uint8 *ram);
23 24
 void system_deo(Uxn *u, Uint8 *d, Uint8 port);
... ...
@@ -117,14 +117,3 @@ uxn_eval(Uxn *u, Uint16 pc)
117 117
 		}
118 118
 	}
119 119
 }
120
-
121
-int
122
-uxn_boot(Uxn *u, Uint8 *ram)
123
-{
124
-	Uint32 i;
125
-	char *cptr = (char *)u;
126
-	for(i = 0; i < sizeof(*u); i++)
127
-		cptr[i] = 0;
128
-	u->ram = ram;
129
-	return 1;
130
-}
... ...
@@ -46,5 +46,4 @@ extern Uint16 dev_vers[0x10], dei_mask[0x10], deo_mask[0x10];
46 46
 
47 47
 /* built-ins */
48 48
 
49
-int uxn_boot(Uxn *u, Uint8 *ram);
50 49
 int uxn_eval(Uxn *u, Uint16 pc);
... ...
@@ -58,7 +58,7 @@ main(int argc, char **argv)
58 58
 	if(argv[i][0] == '-' && argv[i][1] == 'v')
59 59
 		return system_version("Uxncli - Console Varvara Emulator", "9 Aug 2023");
60 60
 	/* Continue.. */
61
-	if(!uxn_boot(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8))))
61
+	if(!system_boot(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8))))
62 62
 		return system_error("Boot", "Failed");
63 63
 	/* Load rom */
64 64
 	if(!system_load(&u, argv[i++]))
... ...
@@ -258,7 +258,7 @@ static int
258 258
 emu_start(Uxn *u, char *rom, int queue)
259 259
 {
260 260
 	free(u->ram);
261
-	if(!uxn_boot(u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8))))
261
+	if(!system_boot(u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8))))
262 262
 		return system_error("Boot", "Failed to start uxn.");
263 263
 	if(!system_load(u, rom))
264 264
 		return system_error("Boot", "Failed to load rom.");