Browse code

Keep boot rom path in system

neauoire authored on 16/08/2023 01:53:51
Showing 4 changed files
... ...
@@ -15,6 +15,8 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15 15
 WITH REGARD TO THIS SOFTWARE.
16 16
 */
17 17
 
18
+char *boot_rom;
19
+
18 20
 static const char *errors[] = {
19 21
 	"underflow",
20 22
 	"overflow",
... ...
@@ -100,6 +102,7 @@ system_init(Uxn *u, Uint8 *ram, char *rom)
100 102
 	u->ram = ram;
101 103
 	if(!system_load(u, rom))
102 104
 		return system_error("Init", "Failed to load rom.");
105
+	boot_rom = rom;
103 106
 	return 1;
104 107
 }
105 108
 
... ...
@@ -15,6 +15,8 @@ WITH REGARD TO THIS SOFTWARE.
15 15
 
16 16
 #define RAM_PAGES 0x10
17 17
 
18
+extern char *boot_rom;
19
+
18 20
 void system_connect(Uint8 device, Uint8 ver, Uint16 dei, Uint16 deo);
19 21
 int system_version(char *emulator, char *date);
20 22
 int system_load(Uxn *u, char *filename);
... ...
@@ -73,7 +73,7 @@ main(int argc, char **argv)
73 73
 	system_connect(0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK);
74 74
 	/* Read flags */
75 75
 	if(argv[i][0] == '-' && argv[i][1] == 'v')
76
-		return system_version("Uxncli - Console Varvara Emulator", "9 Aug 2023");
76
+		return system_version("Uxncli - Console Varvara Emulator", "15 Aug 2023");
77 77
 	if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
78 78
 		return system_error("Init", "Failed to initialize uxn.");
79 79
 	/* Game Loop */
... ...
@@ -58,7 +58,6 @@ static SDL_Thread *stdin_thread;
58 58
 static int window_created = 0;
59 59
 static Uint32 stdin_event, audio0_event, zoom = 1;
60 60
 static Uint64 exec_deadline, deadline_interval, ms_interval;
61
-static char *rom_path;
62 61
 
63 62
 Uint16 dev_vers[0x10], dei_mask[0x10], deo_mask[0x10];
64 63
 
... ...
@@ -271,9 +270,9 @@ static void
271 270
 emu_restart(Uxn *u)
272 271
 {
273 272
 	screen_resize(WIDTH, HEIGHT);
274
-	SDL_SetWindowTitle(emu_window, rom_path);
273
+	SDL_SetWindowTitle(emu_window, boot_rom);
275 274
 	if(!emu_start(u, "launcher.rom"))
276
-		emu_start(u, rom_path);
275
+		emu_start(u, boot_rom);
277 276
 }
278 277
 
279 278
 static int
... ...
@@ -288,7 +287,7 @@ emu_restart_soft(Uxn *u)
288 287
 	u->rst.ptr = 0;
289 288
 	screen_fill(uxn_screen.bg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
290 289
 	screen_fill(uxn_screen.fg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
291
-	if(!system_load(u, rom_path))
290
+	if(!system_load(u, boot_rom))
292 291
 		return system_error("Boot", "Failed to load rom.");
293 292
 	if(!uxn_eval(u, PAGE_PROGRAM))
294 293
 		return system_error("Boot", "Failed to eval rom.");
... ...
@@ -552,19 +551,18 @@ main(int argc, char **argv)
552 551
 	system_connect(0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK);
553 552
 	/* Read flags */
554 553
 	if(argv[i][0] == '-' && argv[i][1] == 'v')
555
-		return system_version("Uxnemu - Graphical Varvara Emulator", "10 Aug 2023");
554
+		return system_version("Uxnemu - Graphical Varvara Emulator", "15 Aug 2023");
556 555
 	if(strcmp(argv[i], "-2x") == 0 || strcmp(argv[i], "-3x") == 0)
557 556
 		set_zoom(argv[i++][1] - '0', 0);
558
-	rom_path = argv[i++];
559 557
 	if(!emu_init())
560 558
 		return system_error("Init", "Failed to initialize varvara.");
561
-	if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), rom_path))
559
+	if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
562 560
 		return system_error("Init", "Failed to initialize uxn.");
563 561
 	/* Game Loop */
564 562
 	u.dev[0x17] = argc - i;
565 563
 	if(uxn_eval(&u, PAGE_PROGRAM)) {
566 564
 		console_listen(&u, i, argc, argv);
567
-		emu_run(&u, rom_path);
565
+		emu_run(&u, boot_rom);
568 566
 	}
569 567
 	return emu_end(&u);
570 568
 }