[Core/MCD] improved ROM file extension renaming to .iso for games with CD support

This commit is contained in:
EkeEke 2015-04-26 18:27:02 +02:00
parent 4a41e0cca7
commit 935a1f68dc

View File

@ -735,19 +735,21 @@ int load_rom(char *filename)
/* try to load CD BOOTROM */ /* try to load CD BOOTROM */
if (load_bios()) if (load_bios())
{ {
char *ptr;
char fname[256]; char fname[256];
int len = strlen(filename);
/* boot from cartridge */ /* boot from cartridge */
scd.cartridge.boot = 0x40; scd.cartridge.boot = 0x40;
/* automatically load associated .iso image */ /* change ROM filename extension to .iso */
strncpy(fname, filename, 256); while (len && (filename[len-1] != '.')) len--;
ptr = strchr(fname,'.'); if (len < 253)
if (ptr && (ptr < &fname[252]))
{ {
strcpy(ptr+1,"iso"); strncpy(fname, filename, len);
strcpy(&fname[len], "iso");
} }
/* automatically load associated .iso image */
cdd_load(fname, (char *)cdc.ram); cdd_load(fname, (char *)cdc.ram);
} }
else else