int Play_CDD_c3 (void) { _msf MSF; int delay, new_lba; CHECK_TRAY_OPEN CHECK_CD_PRESENT if (CD_Load_System == CDROM_) //aggiunta { SCD.Status_CDC &= ~1; // Stop read data with CDC Wait_Read_Complete (); } // MSF of the track to play in TC buffer MSF.M = (CDD.Trans_Comm[2] & 0xF) + (CDD.Trans_Comm[3] & 0xF) * 10; MSF.S = (CDD.Trans_Comm[4] & 0xF) + (CDD.Trans_Comm[5] & 0xF) * 10; MSF.F = (CDD.Trans_Comm[6] & 0xF) + (CDD.Trans_Comm[7] & 0xF) * 10; SCD.Cur_Track = MSF_to_Track (&MSF); new_lba = MSF_to_LBA (&MSF); delay = new_lba - SCD.Cur_LBA; if (delay < 0) delay = -delay; delay >>= 12; SCD.Cur_LBA = new_lba; CDC_Update_Header (); #ifdef DEBUG_CD fprintf (debug_SCD_file, "Read : Cur LBA = %d, M=%d, S=%d, F=%d\n", SCD.Cur_LBA, MSF.M, MSF.S, MSF.F); #endif if (CD_Load_System == CDROM_) { delay += 20; //delay >>= 2; //ASPI_Seek (SCD.Cur_LBA, 1, ASPI_Fast_Seek_COMP); //aggiunta } else if (SCD.Status_CDD != PLAYING) delay += 20; SCD.Status_CDD = PLAYING; CDD.Status = 0x0102; // CDD.Status = COMM_OK; if (File_Add_Delay == 0) File_Add_Delay = delay; if (SCD.TOC.Tracks[SCD.Cur_Track - SCD.TOC.First_Track].Type) { CDD.Control |= 0x0100; // DATA } else { CDD.Control &= ~0x0100; // AUDIO CD_Audio_Starting = 1; if (CD_Load_System == FILE_ISO) FILE_Play_CD_LBA (); } if (SCD.Cur_Track == 100) CDD.Minute = 0x0A02; else CDD.Minute = INT_TO_BCDW (SCD.Cur_Track); CDD.Seconde = 0; CDD.Frame = 0; CDD.Ext = 0; SCD.Status_CDC |= 1; // Read data with CDC CDD_Complete = 1; return 0; }
int MP3_Update_IN(void) { char buf_in[8 * 1024]; int size_read; if (Tracks[Track_Played].F == NULL) return -1; fseek(Tracks[Track_Played].F, Current_IN_Pos, SEEK_SET); size_read = fread(buf_in, 1, 8 * 1024, Tracks[Track_Played].F); Current_IN_Pos += size_read; if (size_read <= 0 || fatal_mp3_error) { int rv; if(!allowContinueToNextTrack) return 6; // go to the next track SCD.Cur_Track = ++Track_Played + 1; // because Cur_Track may or may not have already been incremented, and it's 1-based whereas Track_Played is 0-based played_tracks_linear[SCD.Cur_Track - SCD.TOC.First_Track] = 1; rv = FILE_Play_CD_LBA(1); if(rv) return rv; ResetMP3_Gens(&mp); if (Tracks[Track_Played].Type == TYPE_WAV) { // WAV_Play(); return 4; } else if (Tracks[Track_Played].Type != TYPE_MP3) { return 5; } Current_IN_Pos = MP3_Find_Frame(Tracks[Track_Played].F, 0); fseek(Tracks[Track_Played].F, Current_IN_Pos, SEEK_SET); size_read = fread(buf_in, 1, 8 * 1024, Tracks[Track_Played].F); Current_IN_Pos += size_read; } if(fatal_mp3_error) return 1; if (decodeMP3(&mp, buf_in, size_read, buf_out, 8 * 1024, (int*)&Current_OUT_Size) != MP3_OK) { fseek(Tracks[Track_Played].F, Current_IN_Pos, SEEK_SET); size_read = fread(buf_in, 1, 8 * 1024, Tracks[Track_Played].F); Current_IN_Pos += size_read; if (decodeMP3(&mp, buf_in, size_read, buf_out, 8 * 1024, (int*)&Current_OUT_Size) != MP3_OK) { fatal_mp3_error = 1; return 1; } } return 0; }