void Check_CD_Command(void) { #ifdef DEBUG_CD fprintf(debug_SCD_file, "CHECK CD COMMAND\n"); #endif // Check CDD if (CDD_Complete) { CDD_Complete = 0; #ifdef DEBUG_CD fprintf(debug_SCD_file, "CDD exporting status\n"); fprintf(debug_SCD_file, "Status=%.4X, Minute=%.4X, Seconde=%.4X, Frame=%.4X, Ext=%.4X\n", CDD.Status, CDD.Minute, CDD.Seconde, CDD.Frame, CDD.Ext); #endif CDD_Export_Status(); if (Int_Mask_S68K & 0x10) sub68k_interrupt(4, -1); } // Check CDC if (SCD.Status_CDC & 1) // CDC is reading data ... { #ifdef DEBUG_CD fprintf(debug_SCD_file, "Send a read command\n"); #endif // DATA ? if (SCD.TOC.Tracks[SCD.Cur_Track - SCD.TOC.First_Track].Type) CDD.Control |= 0x0100; else CDD.Control &= ~0x0100; // AUDIO if (File_Add_Delay == 0) { if (CD_Load_System == CDROM_) ASPI_Read_One_LBA_CDC(); else FILE_Read_One_LBA_CDC(); } else File_Add_Delay--; } if (SCD.Status_CDD == FAST_FOW) { SCD.Cur_LBA += 10; CDC_Update_Header(); } else if (SCD.Status_CDD == FAST_REV) { SCD.Cur_LBA -= 10; if (SCD.Cur_LBA < -150) SCD.Cur_LBA = -150; CDC_Update_Header(); } }
/** * CDC_Reset(): Reset the CDC. */ static void CDC_Reset(void) { //int i; // Reseting CDC // NOTE: Clearing sizeof(CDC.Buffer) bytes ((32 * 1024 * 2) + 2352) breaks SegaCD! // This must only clear ((16 * 1024 * 2) + 2352) bytes. memset(CDC.Buffer, 0x00, ((16 * 1024 * 2) + 2352)); CDC_Update_Header(); CDC.COMIN = 0; CDC.IFSTAT = 0xFF; CDC.DAC.N = 0; CDC.DBC.N = 0; CDC.HEAD.N = 0x01000000; CDC.PT.N = 0; CDC.WA.N = 2352 * 2; CDC.STAT.N = 0x00000080; CDC.SBOUT = 0; CDC.IFCTRL = 0; CDC.CTRL.N = 0; CDC_Decode_Reg_Read = 0; }
PICO_INTERNAL int Play_CDD_c3(void) { _msf MSF; int delay, new_lba; CHECK_TRAY_OPEN CHECK_CD_PRESENT // MSF of the track to play in TC buffer MSF.M = (Pico_mcd->s68k_regs[0x38+10+2] & 0xF) * 10 + (Pico_mcd->s68k_regs[0x38+10+3] & 0xF); MSF.S = (Pico_mcd->s68k_regs[0x38+10+4] & 0xF) * 10 + (Pico_mcd->s68k_regs[0x38+10+5] & 0xF); MSF.F = (Pico_mcd->s68k_regs[0x38+10+6] & 0xF) * 10 + (Pico_mcd->s68k_regs[0x38+10+7] & 0xF); Pico_mcd->scd.Cur_Track = MSF_to_Track(&MSF); new_lba = MSF_to_LBA(&MSF); delay = new_lba - Pico_mcd->scd.Cur_LBA; if (delay < 0) delay = -delay; delay >>= 12; if (Pico_mcd->scd.Cur_LBA > 0 && delay < 13) // based on genplus GX delay = 13; Pico_mcd->scd.Cur_LBA = new_lba; CDC_Update_Header(); cdprintf("Read : Cur LBA = %d, M=%d, S=%d, F=%d", Pico_mcd->scd.Cur_LBA, MSF.M, MSF.S, MSF.F); if (Pico_mcd->scd.Status_CDD != PLAYING) delay += 20; Pico_mcd->scd.Status_CDD = PLAYING; Pico_mcd->cdd.Status = 0x0102; // Pico_mcd->cdd.Status = COMM_OK; if (Pico_mcd->scd.File_Add_Delay == 0) Pico_mcd->scd.File_Add_Delay = delay; if (Pico_mcd->scd.Cur_Track == 1) { Pico_mcd->s68k_regs[0x36] |= 0x01; // DATA } else { Pico_mcd->s68k_regs[0x36] &= ~0x01; // AUDIO cdda_start_play(); } if (Pico_mcd->scd.Cur_Track == 100) Pico_mcd->cdd.Minute = 0x0A02; else Pico_mcd->cdd.Minute = INT_TO_BCDW(Pico_mcd->scd.Cur_Track); Pico_mcd->cdd.Seconde = 0; Pico_mcd->cdd.Frame = 0; Pico_mcd->cdd.Ext = 0; Pico_mcd->scd.Status_CDC |= 1; // Read data with CDC Pico_mcd->scd.CDD_Complete = 1; return 0; }
int Seek_CDD_c4 (void) { _msf MSF; CHECK_TRAY_OPEN CHECK_CD_PRESENT // MSF to seek 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); SCD.Cur_LBA = MSF_to_LBA (&MSF); CDC_Update_Header (); SCD.Status_CDC &= ~1; // Stop CDC read if (CD_Load_System == CDROM_) { ASPI_Seek (SCD.Cur_LBA, 1, ASPI_Seek_CDD_c4_COMP); SCD.Status_CDD = READY; CDD.Status = 0x0200; // DATA ? if (SCD.TOC.Tracks[SCD.Cur_Track - SCD.TOC.First_Track].Type) CDD.Control |= 0x0100; else CDD.Control &= 0xFEFF; // AUDIO CDD.Minute = 0; CDD.Seconde = 0; CDD.Frame = 0; CDD.Ext = 0; } else { SCD.Status_CDD = READY; CDD.Status = 0x0200; // DATA ? if (SCD.TOC.Tracks[SCD.Cur_Track - SCD.TOC.First_Track].Type) CDD.Control |= 0x0100; else CDD.Control &= 0xFEFF; // AUDIO CDD.Minute = 0; CDD.Seconde = 0; CDD.Frame = 0; CDD.Ext = 0; } CDD_Complete = 1; return 0; }
PICO_INTERNAL void Check_CD_Command(void) { cdprintf("CHECK CD COMMAND"); // Check CDC if (Pico_mcd->scd.Status_CDC & 1) // CDC is reading data ... { cdprintf("Got a read command"); // DATA ? if (Pico_mcd->scd.Cur_Track == 1) Pico_mcd->s68k_regs[0x36] |= 0x01; else Pico_mcd->s68k_regs[0x36] &= ~0x01; // AUDIO if (Pico_mcd->scd.File_Add_Delay == 0) { FILE_Read_One_LBA_CDC(); } else Pico_mcd->scd.File_Add_Delay--; } // Check CDD if (Pico_mcd->scd.CDD_Complete) { Pico_mcd->scd.CDD_Complete = 0; CDD_Export_Status(); } if (Pico_mcd->scd.Status_CDD == FAST_FOW) { Pico_mcd->scd.Cur_LBA += 10; CDC_Update_Header(); } else if (Pico_mcd->scd.Status_CDD == FAST_REV) { Pico_mcd->scd.Cur_LBA -= 10; if (Pico_mcd->scd.Cur_LBA < -150) Pico_mcd->scd.Cur_LBA = -150; CDC_Update_Header(); } }
int Play_CDD_c3(void) { _msf MSF; int delay, new_lba; CHECK_TRAY_OPEN CHECK_CD_PRESENT if (CD_Load_System == CDROM_) { 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); ASPI_Flush_Cache_CDC(); }
PICO_INTERNAL int Seek_CDD_c4(void) { _msf MSF; CHECK_TRAY_OPEN CHECK_CD_PRESENT // MSF to seek in TC buffer MSF.M = (Pico_mcd->s68k_regs[0x38+10+2] & 0xF) * 10 + (Pico_mcd->s68k_regs[0x38+10+3] & 0xF); MSF.S = (Pico_mcd->s68k_regs[0x38+10+4] & 0xF) * 10 + (Pico_mcd->s68k_regs[0x38+10+5] & 0xF); MSF.F = (Pico_mcd->s68k_regs[0x38+10+6] & 0xF) * 10 + (Pico_mcd->s68k_regs[0x38+10+7] & 0xF); Pico_mcd->scd.Cur_Track = MSF_to_Track(&MSF); Pico_mcd->scd.Cur_LBA = MSF_to_LBA(&MSF); CDC_Update_Header(); Pico_mcd->scd.Status_CDC &= ~1; // Stop CDC read Pico_mcd->scd.Status_CDD = READY; Pico_mcd->cdd.Status = 0x0200; // DATA ? if (Pico_mcd->scd.Cur_Track == 1) Pico_mcd->s68k_regs[0x36] |= 0x01; else Pico_mcd->s68k_regs[0x36] &= ~0x01; // AUDIO Pico_mcd->cdd.Minute = 0; Pico_mcd->cdd.Seconde = 0; Pico_mcd->cdd.Frame = 0; Pico_mcd->cdd.Ext = 0; Pico_mcd->scd.CDD_Complete = 1; return 0; }
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; }