Browse code

Simplified system_cmd

Devine Lu Linvega authored on 31/01/2023 17:49:32
Showing 4 changed files
... ...
@@ -41,15 +41,8 @@ system_inspect(Uxn *u)
41 41
 
42 42
 /* RAM */
43 43
 
44
-Uint8 *
45
-system_init(Mmu *m, Uint16 pages)
46
-{
47
-	m->pages = (Uint8 *)calloc(0x10000 * pages, sizeof(Uint8));
48
-	return m->pages;
49
-}
50
-
51 44
 void
52
-mmu_eval(Uint8 *ram, Uint16 addr)
45
+system_cmd(Uint8 *ram, Uint16 addr)
53 46
 {
54 47
 	Uint16 a = addr, i = 0;
55 48
 	Uint8 o = ram[a++];
... ...
@@ -85,7 +78,7 @@ system_deo(Uxn *u, Uint8 *d, Uint8 port)
85 78
 	switch(port) {
86 79
 	case 0x3:
87 80
 		PEKDEV(a, 0x2);
88
-		mmu_eval(u->ram, a);
81
+		system_cmd(u->ram, a);
89 82
 		break;
90 83
 	case 0xe:
91 84
 		if(u->wst->ptr || u->rst->ptr) system_inspect(u);
... ...
@@ -113,4 +106,3 @@ uxn_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr)
113 106
 	}
114 107
 	return 0;
115 108
 }
116
-
... ...
@@ -11,11 +11,6 @@ WITH REGARD TO THIS SOFTWARE.
11 11
 
12 12
 #define RAM_PAGES 0x10
13 13
 
14
-typedef struct {
15
-	Uint8 *pages;
16
-} Mmu;
17
-
18
-Uint8 *system_init(Mmu *m, Uint16 pages);
19 14
 int system_load(Uxn *u, char *filename);
20
-void system_inspect(Uxn *u);
21 15
 void system_deo(Uxn *u, Uint8 *d, Uint8 port);
16
+void system_inspect(Uxn *u);
... ...
@@ -78,10 +78,9 @@ main(int argc, char **argv)
78 78
 {
79 79
 	Uxn u;
80 80
 	int i;
81
-	Mmu mmu;
82 81
 	if(argc < 2)
83 82
 		return emu_error("Usage", "uxncli game.rom args");
84
-	if(!uxn_boot(&u, system_init(&mmu, RAM_PAGES), emu_dei, emu_deo))
83
+	if(!uxn_boot(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), emu_dei, emu_deo))
85 84
 		return emu_error("Boot", "Failed");
86 85
 	if(!system_load(&u, argv[1]))
87 86
 		return emu_error("Load", "Failed");
... ...
@@ -53,7 +53,6 @@ static Uint32 stdin_event, audio0_event;
53 53
 static Uint64 exec_deadline, deadline_interval, ms_interval;
54 54
 
55 55
 char *rom_path;
56
-Mmu mmu;
57 56
 
58 57
 static int
59 58
 error(char *msg, const char *err)
... ...
@@ -263,8 +262,8 @@ init(void)
263 262
 static int
264 263
 start(Uxn *u, char *rom)
265 264
 {
266
-	free(mmu.pages);
267
-	if(!uxn_boot(u, system_init(&mmu, RAM_PAGES), emu_dei, emu_deo))
265
+	free(u->ram);
266
+	if(!uxn_boot(u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), emu_dei, emu_deo))
268 267
 		return error("Boot", "Failed to start uxn.");
269 268
 	if(!system_load(u, rom))
270 269
 		return error("Boot", "Failed to load rom.");