wav support, better mp3 length handling using .cue
authornotaz <notasas@gmail.com>
Sat, 3 May 2008 16:35:30 +0000 (16:35 +0000)
committernotaz <notasas@gmail.com>
Sat, 3 May 2008 16:35:30 +0000 (16:35 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@436 be3aeb3a-fb24-0410-a615-afba39da0efa

Pico/cd/cd_file.c
Pico/cd/cue.c
Pico/cd/cue.h
Pico/sound/sound.c
platform/base_readme.txt

index b38fd95..1fdbef6 100644 (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++;
index 39c635a..cfd4e27 100644 (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);
index f377aa3..70ade53 100644 (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;
 
index c39d0c1..4c13a2f 100644 (file)
@@ -278,6 +278,11 @@ PICO_INTERNAL void cdda_start_play(void)
   cdda_stream = Pico_mcd->TOC.Tracks[i].F;\r
   PicoCDBufferFlush(); // buffering relies on fp not being touched\r
   pm_seek(cdda_stream, lba_offset * 2352, SEEK_SET);\r
+  if (Pico_mcd->TOC.Tracks[i].ftype == TYPE_WAV)\r
+  {\r
+    // skip headers, assume it's 44kHz stereo uncompressed\r
+    pm_seek(cdda_stream, 44, SEEK_CUR);\r
+  }\r
 }\r
 \r
 \r
index 69ad36a..6561c9b 100644 (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\r
 these files can also be zipped.\r
 \r
-The game must be dumped to ISO format, but BIN can be used too. If you want\r
-CD music, you must use ISO+mp3 files. Audio from BIN files won't be read at\r
-all. Also BIN files are usually larger, so it's better to use ISO. ISO+mp3\r
-files can be named similarly as for other emus.\r
+The game must be dumped to ISO format, but CUE/BIN can be used too. When using\r
+CUE/BIN, you must load .cue file from the menu, or else the emu will not find\r
+audio tracks.\r
+CUE/BIN usually takes a lot of space, so it can be converted to cue/cso/mp3 by\r
+using bin_to_cso_mp3 tool, which is included with the emulator. See readme in\r
+the bin_to_cso_mp3/ directory for details.\r
+\r
+ISO+mp3 files can be named similarly as for other emus.\r
 Here are some examples:\r
 \r
 SonicCD.iso             data track\r
@@ -649,6 +653,11 @@ Additional thanks
 \r
 Changelog\r
 ---------\r
+1.4x\r
+  + Added proper support for cue/bin images, including cdda playback.\r
+    .cue sheets with iso/cso/mp3/wav files listed in them are also supported.\r
+  * Fixed a crash of games using eeprom (introduced in 1.40b).\r
+\r
 1.40c\r
   * Fixed a problem with sound in Marble Madness.\r
   * GP2X: Fixed minor problem with key config.\r