notaz.gp2x.de
/
picodrive.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cd: switch to CD controller code from genplus
[picodrive.git]
/
pico
/
cd
/
cd_file.c
diff --git
a/pico/cd/cd_file.c
b/pico/cd/cd_file.c
index
31efd0e
..
43bbb5d
100644
(file)
--- a/
pico/cd/cd_file.c
+++ b/
pico/cd/cd_file.c
@@
-13,6
+13,16
@@
//#define cdprintf(f,...) printf(f "\n",##__VA_ARGS__) // tmp
//#define cdprintf(f,...) printf(f "\n",##__VA_ARGS__) // tmp
+static void to_upper(char *d, const char *s)
+{
+ for (; *s != 0; d++, s++) {
+ if ('a' <= *s && *s <= 'z')
+ *d = *s - 'a' + 'A';
+ else
+ *d = *s;
+ }
+}
+
static int audio_track_mp3(const char *fname, int index)
{
_scd_track *Tracks = Pico_mcd->TOC.Tracks;
static int audio_track_mp3(const char *fname, int index)
{
_scd_track *Tracks = Pico_mcd->TOC.Tracks;
@@
-27,7
+37,7
@@
static int audio_track_mp3(const char *fname, int index)
fs = ftell(tmp_file); // used to calculate length
fseek(tmp_file, 0, SEEK_SET);
fs = ftell(tmp_file); // used to calculate length
fseek(tmp_file, 0, SEEK_SET);
-#if
DONT_OPEN_MANY_FILES
+#if
def _PSP_FW_VERSION
// some systems (like PSP) can't have many open files at a time,
// so we work with their names instead.
fclose(tmp_file);
// some systems (like PSP) can't have many open files at a time,
// so we work with their names instead.
fclose(tmp_file);
@@
-38,10
+48,10
@@
static int audio_track_mp3(const char *fname, int index)
if (ret != 0 || Tracks[index].KBtps <= 0)
{
elprintf(EL_STATUS, "track %2i: mp3 bitrate %i", index+1, Tracks[index].KBtps);
if (ret != 0 || Tracks[index].KBtps <= 0)
{
elprintf(EL_STATUS, "track %2i: mp3 bitrate %i", index+1, Tracks[index].KBtps);
-#if !DONT_OPEN_MANY_FILES
- fclose(tmp_file);
-#else
+#ifdef _PSP_FW_VERSION
free(tmp_file);
free(tmp_file);
+#else
+ fclose(tmp_file);
#endif
return -1;
}
#endif
return -1;
}
@@
-49,7
+59,7
@@
static int audio_track_mp3(const char *fname, int index)
Tracks[index].F = tmp_file;
// MP3 File
Tracks[index].F = tmp_file;
// MP3 File
- Tracks[index].ftype =
TYPE
_MP3;
+ Tracks[index].ftype =
CT
_MP3;
fs *= 75;
fs /= Tracks[index].KBtps * 1000;
Tracks[index].Length = fs;
fs *= 75;
fs /= Tracks[index].KBtps * 1000;
Tracks[index].Length = fs;
@@
-60,17
+70,15
@@
static int audio_track_mp3(const char *fname, int index)
PICO_INTERNAL int Load_CD_Image(const char *cd_img_name, cd_img_type type)
{
PICO_INTERNAL int Load_CD_Image(const char *cd_img_name, cd_img_type type)
{
- int i, j, num_track, Cur_LBA, index, ret, iso_name_len, missed, cd_img_sectors;
+ int i, j, num_track, Cur_LBA, index, ret;
+ int iso_name_len, missed, cd_img_sectors;
_scd_track *Tracks = Pico_mcd->TOC.Tracks;
_scd_track *Tracks = Pico_mcd->TOC.Tracks;
- char tmp_name[
1024], tmp_ext
[10];
+ char tmp_name[
256], tmp_ext[10], tmp_ext_u
[10];
cue_data_t *cue_data = NULL;
pm_file *pmf;
cue_data_t *cue_data = NULL;
pm_file *pmf;
- static char *exts[] = {
+ static c
onst c
har *exts[] = {
"%02d.mp3", " %02d.mp3", "-%02d.mp3", "_%02d.mp3", " - %02d.mp3",
"%d.mp3", " %d.mp3", "-%d.mp3", "_%d.mp3", " - %d.mp3",
"%02d.mp3", " %02d.mp3", "-%02d.mp3", "_%02d.mp3", " - %02d.mp3",
"%d.mp3", " %d.mp3", "-%d.mp3", "_%d.mp3", " - %d.mp3",
-#if CASE_SENSITIVE_FS
- "%02d.MP3", " %02d.MP3", "-%02d.MP3", "_%02d.MP3", " - %02d.MP3",
-#endif
};
if (PicoCDLoadProgressCB != NULL)
};
if (PicoCDLoadProgressCB != NULL)
@@
-78,14
+86,14
@@
PICO_INTERNAL int Load_CD_Image(const char *cd_img_name, cd_img_type type)
Unload_ISO();
Unload_ISO();
- /* is this .cue? */
- ret = strlen(cd_img_name);
- if (ret >= 3 && strcasecmp(cd_img_name + ret - 3, "cue") == 0)
- cue_data = cue_parse(cd_img_name);
- if (cue_data != NULL)
+ /* is this a .cue? */
+ cue_data = cue_parse(cd_img_name);
+ if (cue_data != NULL) {
cd_img_name = cue_data->tracks[1].fname;
cd_img_name = cue_data->tracks[1].fname;
-
- Tracks[0].ftype = type == CIT_BIN ? TYPE_BIN : TYPE_ISO;
+ Tracks[0].ftype = cue_data->tracks[1].type;
+ }
+ else
+ Tracks[0].ftype = type == CIT_BIN ? CT_BIN : CT_ISO;
Tracks[0].F = pmf = pm_open(cd_img_name);
if (Tracks[0].F == NULL)
Tracks[0].F = pmf = pm_open(cd_img_name);
if (Tracks[0].F == NULL)
@@
-97,7
+105,7
@@
PICO_INTERNAL int Load_CD_Image(const char *cd_img_name, cd_img_type type)
return -1;
}
return -1;
}
- if (Tracks[0].ftype ==
TYPE
_ISO)
+ if (Tracks[0].ftype ==
CT
_ISO)
cd_img_sectors = pmf->size >>= 11; // size in sectors
else cd_img_sectors = pmf->size /= 2352;
Tracks[0].Offset = 0;
cd_img_sectors = pmf->size >>= 11; // size in sectors
else cd_img_sectors = pmf->size /= 2352;
Tracks[0].Offset = 0;
@@
-106,8
+114,9
@@
PICO_INTERNAL int Load_CD_Image(const char *cd_img_name, cd_img_type type)
Tracks[0].MSF.S = 2; // seconds
Tracks[0].MSF.F = 0; // frames
Tracks[0].MSF.S = 2; // seconds
Tracks[0].MSF.F = 0; // frames
- elprintf(EL_STATUS, "Track 1: %02d:%02d:%02d %9i DATA",
- Tracks[0].MSF.M, Tracks[0].MSF.S, Tracks[0].MSF.F, Tracks[0].Length);
+ elprintf(EL_STATUS, "Track 1: %02d:%02d:%02d %9i DATA %s",
+ Tracks[0].MSF.M, Tracks[0].MSF.S, Tracks[0].MSF.F,
+ Tracks[0].Length, cd_img_name);
Cur_LBA = Tracks[0].Length = cd_img_sectors;
Cur_LBA = Tracks[0].Length = cd_img_sectors;
@@
-166,7
+175,7
@@
PICO_INTERNAL int Load_CD_Image(const char *cd_img_name, cd_img_type type)
LBA_to_MSF(Cur_LBA, &Tracks[index].MSF);
Cur_LBA += Tracks[index].Length;
LBA_to_MSF(Cur_LBA, &Tracks[index].MSF);
Cur_LBA += Tracks[index].Length;
- elprintf(EL_STATUS, "Track %2i: %02d:%02d:%02d %9i AUDIO
-
%s", num_track, Tracks[index].MSF.M,
+ elprintf(EL_STATUS, "Track %2i: %02d:%02d:%02d %9i AUDIO %s", num_track, Tracks[index].MSF.M,
Tracks[index].MSF.S, Tracks[index].MSF.F, Tracks[index].Length,
cue_data->tracks[num_track].fname);
}
Tracks[index].MSF.S, Tracks[index].MSF.F, Tracks[index].Length,
cue_data->tracks[num_track].fname);
}
@@
-187,19
+196,32
@@
PICO_INTERNAL int Load_CD_Image(const char *cd_img_name, cd_img_type type)
for (j = 0; j < sizeof(exts)/sizeof(char *); j++)
{
int ext_len;
for (j = 0; j < sizeof(exts)/sizeof(char *); j++)
{
int ext_len;
+ char *p;
+
+ index = num_track - 1;
+
sprintf(tmp_ext, exts[j], i);
ext_len = strlen(tmp_ext);
sprintf(tmp_ext, exts[j], i);
ext_len = strlen(tmp_ext);
+ to_upper(tmp_ext_u, tmp_ext);
memcpy(tmp_name, cd_img_name, iso_name_len + 1);
memcpy(tmp_name, cd_img_name, iso_name_len + 1);
- tmp_name[iso_name_len - 4] = 0;
- strcat(tmp_name, tmp_ext);
+ p = tmp_name + iso_name_len - 4;
-
index = num_track - 1
;
+
strcpy(p, tmp_ext)
;
ret = audio_track_mp3(tmp_name, index);
ret = audio_track_mp3(tmp_name, index);
+ if (ret != 0) {
+ strcpy(p, tmp_ext_u);
+ ret = audio_track_mp3(tmp_name, index);
+ }
+
if (ret != 0 && i > 1 && iso_name_len > ext_len) {
if (ret != 0 && i > 1 && iso_name_len > ext_len) {
-
tmp_name[iso_name_len - ext_len] = 0
;
- strc
at(tmp_name
, tmp_ext);
+
p = tmp_name + iso_name_len - ext_len
;
+ strc
py(p
, tmp_ext);
ret = audio_track_mp3(tmp_name, index);
ret = audio_track_mp3(tmp_name, index);
+ if (ret != 0) {
+ strcpy(p, tmp_ext_u);
+ ret = audio_track_mp3(tmp_name, index);
+ }
}
if (ret == 0)
}
if (ret == 0)
@@
-247,8
+269,8
@@
PICO_INTERNAL void Unload_ISO(void)
{
if (Pico_mcd->TOC.Tracks[i].F != NULL)
{
{
if (Pico_mcd->TOC.Tracks[i].F != NULL)
{
- if (Pico_mcd->TOC.Tracks[i].ftype ==
TYPE
_MP3)
-#if
DONT_OPEN_MANY_FILES
+ if (Pico_mcd->TOC.Tracks[i].ftype ==
CT
_MP3)
+#if
def _PSP_FW_VERSION
free(Pico_mcd->TOC.Tracks[i].F);
#else
fclose(Pico_mcd->TOC.Tracks[i].F);
free(Pico_mcd->TOC.Tracks[i].F);
#else
fclose(Pico_mcd->TOC.Tracks[i].F);
@@
-260,6
+282,7
@@
PICO_INTERNAL void Unload_ISO(void)
memset(Pico_mcd->TOC.Tracks, 0, sizeof(Pico_mcd->TOC.Tracks));
}
memset(Pico_mcd->TOC.Tracks, 0, sizeof(Pico_mcd->TOC.Tracks));
}
+#if 1*0
PICO_INTERNAL int FILE_Read_One_LBA_CDC(void)
{
PICO_INTERNAL int FILE_Read_One_LBA_CDC(void)
{
@@
-376,3
+399,4
@@
PICO_INTERNAL int FILE_Read_One_LBA_CDC(void)
return 0;
}
return 0;
}
+#endif