mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-06 15:48:05 -04:00
cue/bin finally implemented
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@434 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
9037e45d9f
commit
c9e1affca5
13 changed files with 147 additions and 94 deletions
|
@ -126,7 +126,6 @@ PICO_INTERNAL int PicoCdSaveState(void *file)
|
|||
|
||||
if (PicoAHW & PAHW_MCD)
|
||||
{
|
||||
Pico_mcd->m.audio_offset = mp3_get_offset();
|
||||
memset(buff, 0, sizeof(buff));
|
||||
PicoAreaPackCpu(buff, 1);
|
||||
if (Pico_mcd->s68k_regs[3]&4) // 1M mode?
|
||||
|
@ -280,8 +279,8 @@ PICO_INTERNAL int PicoCdLoadState(void *file)
|
|||
if (Pico_mcd->s68k_regs[3]&4)
|
||||
PicoMemResetCDdecode(Pico_mcd->s68k_regs[3]);
|
||||
#endif
|
||||
if (Pico_mcd->m.audio_track > 0 && Pico_mcd->m.audio_track < Pico_mcd->TOC.Last_Track)
|
||||
mp3_start_play(Pico_mcd->TOC.Tracks[Pico_mcd->m.audio_track].F, Pico_mcd->m.audio_offset);
|
||||
if (!(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1))
|
||||
cdda_start_play();
|
||||
// restore hint vector
|
||||
*(unsigned short *)(Pico_mcd->bios + 0x72) = Pico_mcd->m.hint_vector;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,13 @@ void PicoCDBufferFree(void)
|
|||
}
|
||||
|
||||
|
||||
/* this is a try to fight slow SD access of GP2X */
|
||||
void PicoCDBufferFlush(void)
|
||||
{
|
||||
prev_lba = 0x80000000;
|
||||
}
|
||||
|
||||
|
||||
/* this is was a try to fight slow SD access of GP2X */
|
||||
PICO_INTERNAL void PicoCDBufferRead(void *dest, int lba)
|
||||
{
|
||||
int is_bin, offs, read_len, moved = 0;
|
||||
|
|
|
@ -115,8 +115,10 @@ PICO_INTERNAL int Load_CD_Image(const char *cd_img_name, cd_img_type type)
|
|||
if (cue_data->tracks[2].fname == NULL) { // NULL means track2 is in same file as track1
|
||||
Cur_LBA = Tracks[0].Length = cue_data->tracks[2].sector_offset;
|
||||
}
|
||||
i = 100 / cue_data->track_count+1;
|
||||
for (num_track = 2; num_track <= cue_data->track_count; num_track++)
|
||||
{
|
||||
if (PicoCDLoadProgressCB != NULL) PicoCDLoadProgressCB(i * num_track);
|
||||
index = num_track - 1;
|
||||
Cur_LBA += cue_data->tracks[num_track].pregap;
|
||||
if (cue_data->tracks[num_track].type == CT_MP3) {
|
||||
|
@ -128,7 +130,7 @@ 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 = fopen(cue_data->tracks[num_track].fname, "rb");
|
||||
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;
|
||||
|
@ -154,7 +156,7 @@ PICO_INTERNAL int Load_CD_Image(const char *cd_img_name, cd_img_type type)
|
|||
goto finish;
|
||||
}
|
||||
|
||||
/* track autosearch, Gens-like */
|
||||
/* mp3 track autosearch, Gens-like */
|
||||
iso_name_len = strlen(cd_img_name);
|
||||
if (iso_name_len >= sizeof(tmp_name))
|
||||
iso_name_len = sizeof(tmp_name) - 1;
|
||||
|
@ -194,7 +196,7 @@ PICO_INTERNAL int Load_CD_Image(const char *cd_img_name, cd_img_type type)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (ret != 0) missed++;
|
||||
if (ret != 0 && i > 1) missed++;
|
||||
}
|
||||
|
||||
finish:
|
||||
|
@ -225,12 +227,14 @@ PICO_INTERNAL void Unload_ISO(void)
|
|||
{
|
||||
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].type == TYPE_MP3)
|
||||
free(Pico_mcd->TOC.Tracks[i].F);
|
||||
else
|
||||
#endif
|
||||
#else
|
||||
fclose(Pico_mcd->TOC.Tracks[i].F);
|
||||
#endif
|
||||
else
|
||||
pm_close(Pico_mcd->TOC.Tracks[i].F);
|
||||
}
|
||||
}
|
||||
memset(Pico_mcd->TOC.Tracks, 0, sizeof(Pico_mcd->TOC.Tracks));
|
||||
|
@ -239,8 +243,6 @@ PICO_INTERNAL void Unload_ISO(void)
|
|||
|
||||
PICO_INTERNAL int FILE_Read_One_LBA_CDC(void)
|
||||
{
|
||||
// static char cp_buf[2560];
|
||||
|
||||
if (Pico_mcd->s68k_regs[0x36] & 1) // DATA
|
||||
{
|
||||
if (Pico_mcd->TOC.Tracks[0].F == NULL) return -1;
|
||||
|
@ -253,15 +255,6 @@ PICO_INTERNAL int FILE_Read_One_LBA_CDC(void)
|
|||
}
|
||||
else // AUDIO
|
||||
{
|
||||
// int rate, channel;
|
||||
|
||||
// if (Pico_mcd->TOC.Tracks[Pico_mcd->scd.Cur_Track - 1].ftype == TYPE_MP3)
|
||||
{
|
||||
// TODO
|
||||
// MP3_Update(cp_buf, &rate, &channel, 0);
|
||||
// Write_CD_Audio((short *) cp_buf, rate, channel, 588);
|
||||
}
|
||||
|
||||
cdprintf("Read file CDC 1 audio sector :\n");
|
||||
}
|
||||
|
||||
|
@ -324,7 +317,8 @@ PICO_INTERNAL int FILE_Read_One_LBA_CDC(void)
|
|||
{
|
||||
// CAUTION : lookahead bit not implemented
|
||||
|
||||
//memcpy(&Pico_mcd->cdc.Buffer[Pico_mcd->cdc.PT.N], cp_buf, 2352);
|
||||
// this is pretty rough, but oh well - not much depends on this anyway
|
||||
memcpy(&Pico_mcd->cdc.Buffer[Pico_mcd->cdc.PT.N], cdda_out_buffer, 2352);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -362,34 +356,3 @@ PICO_INTERNAL int FILE_Read_One_LBA_CDC(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
PICO_INTERNAL int FILE_Play_CD_LBA(void)
|
||||
{
|
||||
int index = Pico_mcd->scd.Cur_Track - 1;
|
||||
Pico_mcd->m.audio_track = index;
|
||||
|
||||
cdprintf("Play track #%i", Pico_mcd->scd.Cur_Track);
|
||||
|
||||
if (Pico_mcd->TOC.Tracks[index].F == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (Pico_mcd->TOC.Tracks[index].ftype == TYPE_MP3)
|
||||
{
|
||||
int pos1024 = 0;
|
||||
int Track_LBA_Pos = Pico_mcd->scd.Cur_LBA - Track_to_LBA(Pico_mcd->scd.Cur_Track);
|
||||
if (Track_LBA_Pos < 0) Track_LBA_Pos = 0;
|
||||
if (Track_LBA_Pos)
|
||||
pos1024 = Track_LBA_Pos * 1024 / Pico_mcd->TOC.Tracks[index].Length;
|
||||
|
||||
mp3_start_play(Pico_mcd->TOC.Tracks[index].F, pos1024);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ extern "C" {
|
|||
#define TYPE_ISO 1
|
||||
#define TYPE_BIN 2
|
||||
#define TYPE_MP3 3
|
||||
//#define TYPE_WAV 4
|
||||
#define TYPE_WAV 4
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -23,7 +23,6 @@ cd_img_type;
|
|||
PICO_INTERNAL int Load_CD_Image(const char *iso_name, cd_img_type type);
|
||||
PICO_INTERNAL void Unload_ISO(void);
|
||||
PICO_INTERNAL int FILE_Read_One_LBA_CDC(void);
|
||||
PICO_INTERNAL int FILE_Play_CD_LBA(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -489,8 +489,7 @@ PICO_INTERNAL int Play_CDD_c3(void)
|
|||
else
|
||||
{
|
||||
Pico_mcd->s68k_regs[0x36] &= ~0x01; // AUDIO
|
||||
//CD_Audio_Starting = 1;
|
||||
FILE_Play_CD_LBA();
|
||||
cdda_start_play();
|
||||
}
|
||||
|
||||
if (Pico_mcd->scd.Cur_Track == 100) Pico_mcd->cdd.Minute = 0x0A02;
|
||||
|
@ -592,8 +591,7 @@ PICO_INTERNAL int Resume_CDD_c7(void)
|
|||
else
|
||||
{
|
||||
Pico_mcd->s68k_regs[0x36] &= ~0x01; // AUDIO
|
||||
//CD_Audio_Starting = 1;
|
||||
FILE_Play_CD_LBA();
|
||||
cdda_start_play();
|
||||
}
|
||||
|
||||
if (Pico_mcd->scd.Cur_Track == 100) Pico_mcd->cdd.Minute = 0x0A02;
|
||||
|
|
|
@ -60,17 +60,24 @@ static char *get_ext(char *fname)
|
|||
/* note: tracks[0] is not used */
|
||||
cue_data_t *cue_parse(const char *fname)
|
||||
{
|
||||
char buff[256], current_file[256], buff2[32];
|
||||
char buff[256], current_file[256], buff2[32], *current_filep;
|
||||
FILE *f, *tmpf;
|
||||
int ret, count = 0, count_alloc = 2;
|
||||
int ret, count = 0, count_alloc = 2, pending_pregap = 0;
|
||||
cue_data_t *data;
|
||||
void *tmp;
|
||||
|
||||
f = fopen(fname, "r");
|
||||
if (f == NULL) return NULL;
|
||||
|
||||
current_file[0] = 0;
|
||||
snprintf(current_file, sizeof(current_file), "%s", fname);
|
||||
for (current_filep = current_file + strlen(current_file); current_filep > current_file; current_filep--)
|
||||
if (current_filep[-1] == '/' || current_filep[-1] == '\\') break;
|
||||
|
||||
data = calloc(1, sizeof(*data) + count_alloc * sizeof(cue_track));
|
||||
if (data == NULL) {
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (!feof(f))
|
||||
{
|
||||
|
@ -79,11 +86,13 @@ cue_data_t *cue_parse(const char *fname)
|
|||
|
||||
mystrip(buff);
|
||||
if (buff[0] == 0) continue;
|
||||
if (BEGINS(buff, "TITLE ") || BEGINS(buff, "PERFORMER "))
|
||||
if (BEGINS(buff, "REM"))
|
||||
continue;
|
||||
else if (BEGINS(buff, "TITLE ") || BEGINS(buff, "PERFORMER ") || BEGINS(buff, "SONGWRITER "))
|
||||
continue; /* who would put those here? Ignore! */
|
||||
else if (BEGINS(buff, "FILE "))
|
||||
{
|
||||
get_token(buff+5, current_file, sizeof(current_file));
|
||||
get_token(buff+5, current_filep, sizeof(current_file) - (current_filep - current_file));
|
||||
}
|
||||
else if (BEGINS(buff, "TRACK "))
|
||||
{
|
||||
|
@ -107,6 +116,8 @@ cue_data_t *cue_parse(const char *fname)
|
|||
}
|
||||
fclose(tmpf);
|
||||
}
|
||||
data->tracks[count].pregap = pending_pregap;
|
||||
pending_pregap = 0;
|
||||
// track number
|
||||
ret = get_token(buff+6, buff2, sizeof(buff2));
|
||||
if (count != atoi(buff2))
|
||||
|
@ -172,7 +183,7 @@ cue_data_t *cue_parse(const char *fname)
|
|||
data->tracks[count].fname = strdup(current_file);
|
||||
}
|
||||
}
|
||||
else if (BEGINS(buff, "PREGAP "))
|
||||
else if (BEGINS(buff, "PREGAP ") || BEGINS(buff, "POSTGAP "))
|
||||
{
|
||||
int m, s, f;
|
||||
get_token(buff+7, buff2, sizeof(buff2));
|
||||
|
@ -181,7 +192,12 @@ cue_data_t *cue_parse(const char *fname)
|
|||
elprintf(EL_STATUS, "cue: failed to parse: \"%s\"", buff);
|
||||
continue;
|
||||
}
|
||||
data->tracks[count].pregap = m*60*75 + s*75 + f;
|
||||
// pregap overrides previous postgap?
|
||||
// by looking at some .cues produced by some programs I've decided that..
|
||||
if (BEGINS(buff, "PREGAP "))
|
||||
data->tracks[count].pregap = m*60*75 + s*75 + f;
|
||||
else
|
||||
pending_pregap = m*60*75 + s*75 + f;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue