Mercurial > repos > blastem
comparison blastem.c @ 2401:34b4ff091891
Fix crash when loading a subsequent ROM after lock-on
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 01 Jan 2024 19:27:31 -0800 |
parents | 59fd8aa352e2 |
children | 6f8400ce7a0f |
comparison
equal
deleted
inserted
replaced
2400:c97609fe8315 | 2401:34b4ff091891 |
---|---|
434 int num_parts = parts[0] ? 5 : 3; | 434 int num_parts = parts[0] ? 5 : 3; |
435 if (!parts[4]) { | 435 if (!parts[4]) { |
436 num_parts -= 2; | 436 num_parts -= 2; |
437 } | 437 } |
438 current_system->next_rom = alloc_concat_m(num_parts, start); | 438 current_system->next_rom = alloc_concat_m(num_parts, start); |
439 if (cart.chain) { | |
440 parts[0] = cart.chain->dir; | |
441 parts[2] = cart.chain->name; | |
442 parts[4] = cart.chain->extension; | |
443 start = parts[0] ? parts : parts + 2; | |
444 num_parts = parts[0] ? 5 : 3; | |
445 char *lock_on_path = alloc_concat_m(num_parts, start); | |
446 load_media(lock_on_path, cart.chain, NULL); | |
447 free(lock_on_path); | |
448 } | |
439 system_request_exit(current_system, 1); | 449 system_request_exit(current_system, 1); |
440 } | 450 } |
441 | 451 |
442 void lockon_media(char *lock_on_path) | 452 void lockon_media(char *lock_on_path) |
443 { | 453 { |
444 reload_media(); | |
445 cart.chain = &lock_on; | |
446 free(lock_on.dir); | 454 free(lock_on.dir); |
447 free(lock_on.name); | 455 free(lock_on.name); |
448 free(lock_on.extension); | 456 free(lock_on.extension); |
449 load_media(lock_on_path, &lock_on, NULL); | 457 if (lock_on_path) { |
458 reload_media(); | |
459 cart.chain = &lock_on; | |
460 load_media(lock_on_path, &lock_on, NULL); | |
461 } else { | |
462 lock_on.dir = NULL; | |
463 lock_on.name = NULL; | |
464 lock_on.extension = NULL; | |
465 cart.chain = NULL; | |
466 } | |
450 } | 467 } |
451 | 468 |
452 static uint32_t opts = 0; | 469 static uint32_t opts = 0; |
453 static uint8_t force_region = 0; | 470 static uint8_t force_region = 0; |
454 void init_system_with_media(const char *path, system_type force_stype) | 471 void init_system_with_media(const char *path, system_type force_stype) |