wav support, better mp3 length handling using .cue

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@436 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2008-05-03 16:35:30 +00:00
parent c0fcf293c1
commit 0bccafebb6
5 changed files with 55 additions and 16 deletions

View file

@ -105,7 +105,7 @@ 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
elprintf(EL_STATUS, "Track 0: %02d:%02d:%02d %9i DATA",
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);
Cur_LBA = Tracks[0].Length = cd_img_sectors;
@ -130,12 +130,24 @@ PICO_INTERNAL int Load_CD_Image(const char *cd_img_name, cd_img_type type)
Tracks[index].ftype = cue_data->tracks[num_track].type;
if (cue_data->tracks[num_track].fname != NULL)
{
Tracks[index].F = pm_open(cue_data->tracks[num_track].fname);
elprintf(EL_STATUS, "track %2i (%s): can't determine length",
cue_data->tracks[num_track].fname);
Tracks[index].Length = 2*75;
Tracks[index].Offset = 0;
} else {
pm_file *pmfn = pm_open(cue_data->tracks[num_track].fname);
if (pmfn != NULL)
{
// addume raw, ignore header for wav..
Tracks[index].F = pmfn;
Tracks[index].Length = pmfn->size / 2352;
Tracks[index].Offset = cue_data->tracks[num_track].sector_offset;
}
else
{
elprintf(EL_STATUS, "track %2i (%s): can't determine length",
num_track, cue_data->tracks[num_track].fname);
Tracks[index].Length = 2*75;
Tracks[index].Offset = 0;
}
}
else
{
if (num_track < cue_data->track_count)
Tracks[index].Length = cue_data->tracks[num_track+1].sector_offset -
cue_data->tracks[num_track].sector_offset;
@ -145,10 +157,14 @@ PICO_INTERNAL int Load_CD_Image(const char *cd_img_name, cd_img_type type)
}
}
if (cue_data->tracks[num_track].sector_xlength != 0)
// overriden by custom cue command
Tracks[index].Length = cue_data->tracks[num_track].sector_xlength;
LBA_to_MSF(Cur_LBA, &Tracks[index].MSF);
Cur_LBA += Tracks[index].Length;
elprintf(EL_STATUS, "Track %2i: %02d:%02d:%02d %9i AUDIO - %s", index, 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);
}
@ -188,7 +204,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;
elprintf(EL_STATUS, "Track %2i: %02d:%02d:%02d %9i AUDIO - %s", index, 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, tmp_name);
num_track++;

View file

@ -86,9 +86,7 @@ cue_data_t *cue_parse(const char *fname)
mystrip(buff);
if (buff[0] == 0) continue;
if (BEGINS(buff, "REM"))
continue;
else if (BEGINS(buff, "TITLE ") || BEGINS(buff, "PERFORMER ") || BEGINS(buff, "SONGWRITER "))
if (BEGINS(buff, "TITLE ") || BEGINS(buff, "PERFORMER ") || BEGINS(buff, "SONGWRITER "))
continue; /* who would put those here? Ignore! */
else if (BEGINS(buff, "FILE "))
{
@ -199,6 +197,16 @@ cue_data_t *cue_parse(const char *fname)
else
pending_pregap = m*60*75 + s*75 + f;
}
else if (BEGINS(buff, "REM LENGTH ")) // custom "extension"
{
int m, s, f;
get_token(buff+11, buff2, sizeof(buff2));
ret = sscanf(buff2, "%d:%d:%d", &m, &s, &f);
if (ret != 3) continue;
data->tracks[count].sector_xlength = m*60*75 + s*75 + f;
}
else if (BEGINS(buff, "REM"))
continue;
else
{
elprintf(EL_STATUS, "cue: unhandled line: \"%s\"", buff);

View file

@ -13,6 +13,7 @@ typedef struct
char *fname;
int pregap; /* pregap for current track */
int sector_offset; /* in current file */
int sector_xlength;
cue_track_type type;
} cue_track;

View file

@ -278,6 +278,11 @@ PICO_INTERNAL void cdda_start_play(void)
cdda_stream = Pico_mcd->TOC.Tracks[i].F;
PicoCDBufferFlush(); // buffering relies on fp not being touched
pm_seek(cdda_stream, lba_offset * 2352, SEEK_SET);
if (Pico_mcd->TOC.Tracks[i].ftype == TYPE_WAV)
{
// skip headers, assume it's 44kHz stereo uncompressed
pm_seek(cdda_stream, 44, SEEK_CUR);
}
}

View file

@ -81,10 +81,14 @@ EU: eu_mcd1_9210.bin eu_mcd2_9303.bin eu_mcd2_9306.bin
JP: jp_mcd1_9112.bin jp_mcd1_9111.bin
these files can also be zipped.
The game must be dumped to ISO format, but BIN can be used too. If you want
CD music, you must use ISO+mp3 files. Audio from BIN files won't be read at
all. Also BIN files are usually larger, so it's better to use ISO. ISO+mp3
files can be named similarly as for other emus.
The game must be dumped to ISO format, but CUE/BIN can be used too. When using
CUE/BIN, you must load .cue file from the menu, or else the emu will not find
audio tracks.
CUE/BIN usually takes a lot of space, so it can be converted to cue/cso/mp3 by
using bin_to_cso_mp3 tool, which is included with the emulator. See readme in
the bin_to_cso_mp3/ directory for details.
ISO+mp3 files can be named similarly as for other emus.
Here are some examples:
SonicCD.iso data track
@ -649,6 +653,11 @@ Additional thanks
Changelog
---------
1.4x
+ Added proper support for cue/bin images, including cdda playback.
.cue sheets with iso/cso/mp3/wav files listed in them are also supported.
* Fixed a crash of games using eeprom (introduced in 1.40b).
1.40c
* Fixed a problem with sound in Marble Madness.
* GP2X: Fixed minor problem with key config.