commit 245ad45

Devine Lu Linvega  ·  2022-06-13 17:37:18 +0000 UTC
parent 95a28d6
Keep rom path in memory
1 files changed,  +7, -4
+7, -4
 1@@ -31,6 +31,8 @@ static Display *display;
 2 static Visual *visual;
 3 static Window window;
 4 
 5+char *rom_path;
 6+
 7 #define WIDTH (64 * 8)
 8 #define HEIGHT (40 * 8)
 9 
10@@ -106,7 +108,6 @@ emu_start(Uxn *u, char *rom)
11 		return emu_error("Boot", "Failed");
12 	if(!load_rom(u, rom))
13 		return emu_error("Load", "Failed");
14-	fprintf(stderr, "Loaded %s\n", rom);
15 	u->dei = emu_dei;
16 	u->deo = emu_deo;
17 	screen_resize(&uxn_screen, WIDTH, HEIGHT);
18@@ -168,7 +169,8 @@ emu_event(Uxn *u)
19 		if(sym == XK_F2)
20 			system_inspect(u);
21 		if(sym == XK_F4)
22-			emu_start(u, "boot.rom");
23+			if(!emu_start(u, "boot.rom"))
24+				emu_start(u, rom_path);
25 		controller_down(u, &u->dev[0x80], get_button(sym));
26 		controller_key(u, &u->dev[0x80], sym < 0x80 ? sym : (Uint8)buf[0]);
27 	} break;
28@@ -227,11 +229,12 @@ main(int argc, char **argv)
29 	static const struct itimerspec screen_tspec = {{0, 16666666}, {0, 16666666}};
30 	if(argc < 2)
31 		return emu_error("Usage", "uxn11 game.rom args");
32+	rom_path = argv[1];
33 	/* start sequence */
34 	u.ram = NULL;
35-	if(!emu_start(&u, argv[1]))
36+	if(!emu_start(&u, rom_path))
37 		return emu_error("Start", "Failed");
38-	if(!init(argv[1]))
39+	if(!init(rom_path))
40 		return emu_error("Init", "Failed");
41 	/* console vector */
42 	for(i = 2; i < argc; i++) {