comparison blastem.c @ 1128:093c19f34dfd

Detect failures to initialize a system context and report an error rather than crashing
author Michael Pavone <pavone@retrodev.com>
date Tue, 27 Dec 2016 18:58:31 -0800
parents 45db303fc705
children 4490c9c12272
comparison
equal deleted inserted replaced
1127:cb4771f4543a 1128:093c19f34dfd
337 render_init(width, height, "BlastEm", fullscreen); 337 render_init(width, height, "BlastEm", fullscreen);
338 } 338 }
339 339
340 rom_info info; 340 rom_info info;
341 current_system = alloc_config_system(stype, cart, rom_size, lock_on, lock_on_size, menu ? 0 : opts, force_region, &info); 341 current_system = alloc_config_system(stype, cart, rom_size, lock_on, lock_on_size, menu ? 0 : opts, force_region, &info);
342 if (!current_system) {
343 fatal_error("Failed to detect system type for %s\n", romfname);
344 }
342 setup_saves(romfname, &info, current_system); 345 setup_saves(romfname, &info, current_system);
343 update_title(info.name); 346 update_title(info.name);
344 if (menu) { 347 if (menu) {
345 menu_context = current_system; 348 menu_context = current_system;
346 } else { 349 } else {
369 if (!(rom_size = load_rom(menu_context->next_rom, &cart, &stype))) { 372 if (!(rom_size = load_rom(menu_context->next_rom, &cart, &stype))) {
370 fatal_error("Failed to open %s for reading\n", menu_context->next_rom); 373 fatal_error("Failed to open %s for reading\n", menu_context->next_rom);
371 } 374 }
372 //allocate new genesis context 375 //allocate new genesis context
373 game_context = alloc_config_system(stype, cart, rom_size, lock_on, lock_on_size, opts,force_region, &info); 376 game_context = alloc_config_system(stype, cart, rom_size, lock_on, lock_on_size, opts,force_region, &info);
377 if (!game_context) {
378 fatal_error("Failed to detect system type for %s\n", menu_context->next_rom);
379 }
374 menu_context->next_context = game_context; 380 menu_context->next_context = game_context;
375 game_context->next_context = menu_context; 381 game_context->next_context = menu_context;
376 setup_saves(menu_context->next_rom, &info, game_context); 382 setup_saves(menu_context->next_rom, &info, game_context);
377 update_title(info.name); 383 update_title(info.name);
378 free(menu_context->next_rom); 384 free(menu_context->next_rom);