comparison segacd.c @ 2160:3f09312685e3

Fix loading CD bios from absolute path
author Michael Pavone <pavone@retrodev.com>
date Tue, 24 May 2022 18:31:12 -0700
parents 2da377ea932f
children 4fbe1e7c4a73
comparison
equal deleted inserted replaced
2159:2ed402b4c1fb 2160:3f09312685e3
1424 key = "system\0scd_bios_jp\0"; 1424 key = "system\0scd_bios_jp\0";
1425 } else { 1425 } else {
1426 key = "system\0scd_bios_us\0"; 1426 key = "system\0scd_bios_us\0";
1427 } 1427 }
1428 char *bios_path = tern_find_path_default(config, key, (tern_val){.ptrval = "cdbios.bin"}, TVAL_PTR).ptrval; 1428 char *bios_path = tern_find_path_default(config, key, (tern_val){.ptrval = "cdbios.bin"}, TVAL_PTR).ptrval;
1429 cd->rom = (uint16_t *)read_bundled_file(bios_path, &firmware_size); 1429 if (is_absolute_path(bios_path)) {
1430 FILE *f = fopen(bios_path, "rb");
1431 if (f) {
1432 long to_read = file_size(f);
1433 cd->rom = malloc(to_read);
1434 firmware_size = fread(cd->rom, 1, to_read, f);
1435 if (!firmware_size) {
1436 free(cd->rom);
1437 cd->rom = NULL;
1438 }
1439 fclose(f);
1440 }
1441 } else {
1442 cd->rom = (uint16_t *)read_bundled_file(bios_path, &firmware_size);
1443 }
1430 if (!cd->rom) { 1444 if (!cd->rom) {
1431 fatal_error("Failed to load Sega CD BIOS from %s\n", bios_path); 1445 fatal_error("Failed to load Sega CD BIOS from %s\n", bios_path);
1432 } 1446 }
1433 uint32_t adjusted_size = nearest_pow2(firmware_size); 1447 uint32_t adjusted_size = nearest_pow2(firmware_size);
1434 if (adjusted_size != firmware_size) { 1448 if (adjusted_size != firmware_size) {