Example #1
0
static unsigned int LBA_to_Track(int lba)
{
	_msf MSF;

	LBA_to_MSF(lba, &MSF);
	return MSF_to_Track(&MSF);
}
Example #2
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;
}
Example #3
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;
}
Example #4
0
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();
	}
Example #5
0
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;
}
Example #6
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;
}