From 935a1f68dc73f2fa5454336b5c6760d3502d770b Mon Sep 17 00:00:00 2001 From: EkeEke Date: Sun, 26 Apr 2015 18:27:02 +0200 Subject: [PATCH] [Core/MCD] improved ROM file extension renaming to .iso for games with CD support --- core/loadrom.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/loadrom.c b/core/loadrom.c index e21f91b..798b931 100644 --- a/core/loadrom.c +++ b/core/loadrom.c @@ -735,19 +735,21 @@ int load_rom(char *filename) /* try to load CD BOOTROM */ if (load_bios()) { - char *ptr; char fname[256]; + int len = strlen(filename); /* boot from cartridge */ scd.cartridge.boot = 0x40; - /* automatically load associated .iso image */ - strncpy(fname, filename, 256); - ptr = strchr(fname,'.'); - if (ptr && (ptr < &fname[252])) + /* change ROM filename extension to .iso */ + while (len && (filename[len-1] != '.')) len--; + if (len < 253) { - strcpy(ptr+1,"iso"); + strncpy(fname, filename, len); + strcpy(&fname[len], "iso"); } + + /* automatically load associated .iso image */ cdd_load(fname, (char *)cdc.ram); } else