diff --git a/genplus-gx/core/cd_hw/cdd.c b/genplus-gx/core/cd_hw/cdd.c index 12c0f9f55e..9b7e456312 100644 --- a/genplus-gx/core/cd_hw/cdd.c +++ b/genplus-gx/core/cd_hw/cdd.c @@ -134,14 +134,33 @@ typedef struct void (*cdd_readcallback)(int lba, void *dest); } frontendcd_t; -int cdd_load(void) +int cdd_load(char *header) { frontendcd_t fecd; + char data[2048]; + int startoffs; + + int bytes = sizeof(frontendcd_t); if (load_archive("PRIMARY_CD", (unsigned char *)&fecd, bytes, NULL) != bytes) return 0; + + // look for valid header + fecd.cdd_readcallback(0, data); + if (memcmp("SEGADISCSYSTEM", data, 14) == 0) + startoffs = 0; + else if (memcmp("SEGADISCSYSTEM", data + 16, 14) == 0) + startoffs = 16; + else + return 0; + // copy security block + memcpy(header, data + startoffs, 0x210); + + // copy disk information cdd_readcallback = fecd.cdd_readcallback; memcpy(&cdd.toc, &fecd.toc, sizeof(toc_t)); + + cdd.loaded = 1; return 1; } diff --git a/genplus-gx/core/cd_hw/cdd.h b/genplus-gx/core/cd_hw/cdd.h index a0ba402282..b0509c8a27 100644 --- a/genplus-gx/core/cd_hw/cdd.h +++ b/genplus-gx/core/cd_hw/cdd.h @@ -96,7 +96,7 @@ extern void cdd_init(blip_t* left, blip_t* right); extern void cdd_reset(void); extern int cdd_context_save(uint8 *state); extern int cdd_context_load(uint8 *state); -extern int cdd_load(void); +extern int cdd_load(char *header); extern void cdd_unload(void); extern void cdd_read_data(uint8 *dst); extern void cdd_read_audio(unsigned int samples); diff --git a/genplus-gx/core/loadrom.c b/genplus-gx/core/loadrom.c index e2477a0c9f..fa5a132f7a 100644 --- a/genplus-gx/core/loadrom.c +++ b/genplus-gx/core/loadrom.c @@ -541,7 +541,7 @@ int load_rom(char *filename) } /* auto-detect CD image files */ - size = cdd_load(); + size = cdd_load((char *)(cart.rom)); if (size < 0) { /* error opening file */ @@ -730,7 +730,7 @@ int load_rom(char *filename) /* automatically load associated .iso image */ strncpy(&filename[strlen(filename) - 4], ".iso", 4); - cdd_load(); // should this be checked for failure? + cdd_load((char *)cdc.ram); // should this be checked for failure? } else { diff --git a/output/dll/libgenplusgx.dll b/output/dll/libgenplusgx.dll index 91fde44270..e1ad16272a 100644 Binary files a/output/dll/libgenplusgx.dll and b/output/dll/libgenplusgx.dll differ