commit 07b6002

Devine Lu Linvega  ·  2024-06-29 19:12:13 +0000 UTC
parent 8281131
Removed indirections in system device
3 files changed,  +22, -22
+19, -19
 1@@ -19,25 +19,25 @@ char *boot_rom;
 2 Uint16 dev_vers[0x10];
 3 
 4 static void
 5-system_zero(Uxn *u, int soft)
 6+system_zero(int soft)
 7 {
 8 	int i;
 9 	for(i = 0x100 * soft; i < 0x10000; i++)
10-		u->ram[i] = 0;
11+		uxn.ram[i] = 0;
12 	for(i = 0x0; i < 0x100; i++)
13-		u->dev[i] = 0;
14-	u->wst.ptr = 0;
15-	u->rst.ptr = 0;
16+		uxn.dev[i] = 0;
17+	uxn.wst.ptr = 0;
18+	uxn.rst.ptr = 0;
19 }
20 
21 static int
22-system_load(Uxn *u, char *filename)
23+system_load(char *filename)
24 {
25 	FILE *f = fopen(filename, "rb");
26 	if(f) {
27-		int i = 0, l = fread(&u->ram[PAGE_PROGRAM], 0x10000 - PAGE_PROGRAM, 1, f);
28+		int i = 0, l = fread(&uxn.ram[PAGE_PROGRAM], 0x10000 - PAGE_PROGRAM, 1, f);
29 		while(l && ++i < RAM_PAGES)
30-			l = fread(u->ram + 0x10000 * i, 0x10000, 1, f);
31+			l = fread(uxn.ram + 0x10000 * i, 0x10000, 1, f);
32 		fclose(f);
33 	}
34 	return !!f;
35@@ -61,18 +61,18 @@ system_error(char *msg, const char *err)
36 }
37 
38 void
39-system_inspect(Uxn *u)
40+system_inspect(void)
41 {
42-	fprintf(stderr, "WST "), system_print(&u->wst);
43-	fprintf(stderr, "RST "), system_print(&u->rst);
44+	fprintf(stderr, "WST "), system_print(&uxn.wst);
45+	fprintf(stderr, "RST "), system_print(&uxn.rst);
46 }
47 
48 void
49-system_reboot(Uxn *u, char *rom, int soft)
50+system_reboot(char *rom, int soft)
51 {
52-	system_zero(u, soft);
53-	if(system_load(u, boot_rom))
54-		if(uxn_eval(u, PAGE_PROGRAM))
55+	system_zero(soft);
56+	if(system_load(boot_rom))
57+		if(uxn_eval(&uxn, PAGE_PROGRAM))
58 			boot_rom = rom;
59 }
60 
61@@ -80,9 +80,9 @@ int
62 system_boot(Uint8 *ram, char *rom)
63 {
64 	uxn.ram = ram;
65-	system_zero(&uxn, 0);
66-	if(!system_load(&uxn, rom))
67-		if(!system_load(&uxn, "boot.rom"))
68+	system_zero(0);
69+	if(!system_load(rom))
70+		if(!system_load("boot.rom"))
71 			return system_error("Could not load rom", rom);
72 	boot_rom = rom;
73 	return 1;
74@@ -140,7 +140,7 @@ system_deo(Uxn *u, Uint8 *d, Uint8 port)
75 		u->rst.ptr = d[5];
76 		break;
77 	case 0xe:
78-		system_inspect(u);
79+		system_inspect();
80 		break;
81 	}
82 }
+2, -2
 1@@ -12,8 +12,8 @@ WITH REGARD TO THIS SOFTWARE.
 2 #define SYSTEM_VERSION 2
 3 #define RAM_PAGES 0x10
 4 
 5-void system_reboot(Uxn *u, char *rom, int soft);
 6-void system_inspect(Uxn *u);
 7+void system_reboot(char *rom, int soft);
 8+void system_inspect();
 9 int system_error(char *msg, const char *err);
10 int system_boot(Uint8 *ram, char *rom);
11 
+1, -1
1@@ -94,7 +94,7 @@ emu_restart(char *rom, int soft)
2 	screen_resize(WIDTH, HEIGHT, uxn_screen.scale);
3 	screen_rect(uxn_screen.bg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
4 	screen_rect(uxn_screen.fg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
5-	system_reboot(&uxn, rom, soft);
6+	system_reboot(rom, soft);
7 }
8 
9 static int