\r
#include <Pico/PicoInt.h>\r
#include <Pico/Patch.h>\r
+#include <Pico/cd/cue.h>\r
#include <zlib/zlib.h>\r
\r
#if defined(__GP2X__)\r
{\r
unsigned char buf[32];\r
pm_file *cd_f;\r
- int type = 0, region = 4; // 1: Japan, 4: US, 8: Europe\r
- char ext[5];\r
+ int region = 4; // 1: Japan, 4: US, 8: Europe\r
+ char ext[5], *fname = romFileName;\r
+ cue_track_type type = CT_UNKNOWN;\r
+ cue_data_t *cue_data = NULL;\r
\r
get_ext(romFileName, ext);\r
+ if (strcasecmp(ext, ".cue") == 0) {\r
+ cue_data = cue_parse(romFileName);\r
+ if (cue_data != NULL) {\r
+ fname = cue_data->tracks[1].fname;\r
+ type = cue_data->tracks[1].type;\r
+ }\r
+ }\r
+\r
+ cd_f = pm_open(fname);\r
+ if (cue_data != NULL)\r
+ cue_destroy(cue_data);\r
\r
- cd_f = pm_open(romFileName);\r
if (!cd_f) return 0; // let the upper level handle this\r
\r
if (pm_read(buf, 32, cd_f) != 32) {\r
return 0;\r
}\r
\r
- if (!strncasecmp("SEGADISCSYSTEM", (char *)buf+0x00, 14)) type = 1; // Sega CD (ISO)\r
- if (!strncasecmp("SEGADISCSYSTEM", (char *)buf+0x10, 14)) type = 2; // Sega CD (BIN)\r
- if (type == 0) {\r
+ if (!strncasecmp("SEGADISCSYSTEM", (char *)buf+0x00, 14)) {\r
+ if (type && type != CT_ISO)\r
+ elprintf(EL_STATUS, ".cue has wrong type: %i", type);\r
+ type = CT_ISO; // Sega CD (ISO)\r
+ }\r
+ if (!strncasecmp("SEGADISCSYSTEM", (char *)buf+0x10, 14)) {\r
+ if (type && type != CT_BIN)\r
+ elprintf(EL_STATUS, ".cue has wrong type: %i", type);\r
+ type = CT_BIN; // Sega CD (BIN)\r
+ }\r
+\r
+ if (type == CT_UNKNOWN) {\r
pm_close(cd_f);\r
return 0;\r
}\r
\r
- pm_seek(cd_f, (type == 1) ? 0x100 : 0x110, SEEK_SET);\r
+ pm_seek(cd_f, (type == CT_ISO) ? 0x100 : 0x110, SEEK_SET);\r
pm_read(id_header, sizeof(id_header), cd_f);\r
\r
/* it seems we have a CD image here. Try to detect region now.. */\r
- pm_seek(cd_f, (type == 1) ? 0x100+0x10B : 0x110+0x10B, SEEK_SET);\r
+ pm_seek(cd_f, (type == CT_ISO) ? 0x100+0x10B : 0x110+0x10B, SEEK_SET);\r
pm_read(buf, 1, cd_f);\r
pm_close(cd_f);\r
\r
if (buf[0] == 0xa1) region = 1; // JAP\r
\r
lprintf("detected %s Sega/Mega CD image with %s region\n",\r
- type == 2 ? "BIN" : "ISO", region != 4 ? (region == 8 ? "EU" : "JAP") : "USA");\r
+ type == CT_BIN ? "BIN" : "ISO", region != 4 ? (region == 8 ? "EU" : "JAP") : "USA");\r
\r
if (pregion != NULL) *pregion = region;\r
\r
Pico/VideoPort.o Pico/Draw2.o Pico/Draw.o Pico/Patch.o
# Pico - CD
OBJS += Pico/cd/Pico.o Pico/cd/Memory.o Pico/cd/Sek.o Pico/cd/LC89510.o \
- Pico/cd/cd_sys.o Pico/cd/cd_file.o Pico/cd/gfx_cd.o \
+ Pico/cd/cd_sys.o Pico/cd/cd_file.o Pico/cd/cue.o Pico/cd/gfx_cd.o \
Pico/cd/Area.o Pico/cd/Misc.o Pico/cd/pcm.o Pico/cd/buffering.o
+# Pico - Pico
+OBJS += Pico/Pico/Pico.o Pico/Pico/Memory.o
# Pico - sound
OBJS += Pico/sound/sound.o Pico/sound/sn76496.o Pico/sound/ym2612.o Pico/sound/mix.o
# Pico - carthw
endif
vpath %.c = ../..
-DIRS = platform platform/gp2x platform/common Pico Pico/cd Pico/sound Pico/carthw/svp \
+DIRS = platform platform/gp2x platform/common Pico Pico/cd Pico/Pico Pico/sound Pico/carthw/svp \
zlib unzip cpu cpu/musashi cpu/fame cpu/mz80 cpu/cz80
all: mkdirs PicoDrive