Esempio n. 1
0
s32  CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) {
  char temptime[3];
  int i;
  int pos;
  u32 tracklsn;

#ifdef VERBOSE_FUNCTION_INTERFACE
  PrintLog("CDVDiso interface: CDVDreadSubQ()");
#endif /* VERBOSE_FUNCTION_INTERFACE */

  if(isofile == NULL)  return(-1);
  if(deviceopencount > 0) {
    deviceopencount--;
    if(deviceopencount > 0)  return(-1);
  } // ENDIF- Still simulating device tray open?

  if((isofile->cdvdtype == CDVD_TYPE_PS2DVD) ||
     (isofile->cdvdtype == CDVD_TYPE_DVDV)) {
    return(-1); // DVDs don't have SubQ data
  } // ENDIF- Trying to get a SubQ from a DVD?

  // fake it
  i = BCDTOHEX(isofile->toc[7]);
  pos = i * 10;
  pos += 30;
  temptime[0] = BCDTOHEX(isofile->toc[pos + 7]);
  temptime[1] = BCDTOHEX(isofile->toc[pos + 8]);
  temptime[2] = BCDTOHEX(isofile->toc[pos + 9]);
  tracklsn = MSFtoLBA(temptime);
  while((i < BCDTOHEX(isofile->toc[17])) && (tracklsn < lsn)) {
    i++;
    pos = i * 10;
    pos += 30;
    temptime[0] = BCDTOHEX(isofile->toc[pos + 7]);
    temptime[1] = BCDTOHEX(isofile->toc[pos + 8]);
    temptime[2] = BCDTOHEX(isofile->toc[pos + 9]);
    tracklsn = MSFtoLBA(temptime);
  } // ENDIF- Loop through tracks searching for lsn track
  i--;

  subq->ctrl       = 4;
  subq->mode       = 1;
  subq->trackNum   = HEXTOBCD(i);
  subq->trackIndex = HEXTOBCD(i);
	
  LBAtoMSF(lsn - tracklsn, temptime);
  subq->trackM = HEXTOBCD(temptime[0]);
  subq->trackS = HEXTOBCD(temptime[1]);
  subq->trackF = HEXTOBCD(temptime[2]);
	
  subq->pad = 0;
	
  // lba_to_msf(lsn + (2*75), &min, &sec, &frm);
  LBAtoMSF(lsn, temptime);
  subq->discM = HEXTOBCD(temptime[0]);
  subq->discS = HEXTOBCD(temptime[1]);
  subq->discF = HEXTOBCD(temptime[2]);

  return(0);
} // END CDVDreadSubQ()
Esempio n. 2
0
s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd)
{
    u8 j;
    u16 k;
    char temptime[3];

#ifdef VERBOSE_FUNCTION
    PrintLog("CDVD driver: CDgetTD()");
#endif /* VERBOSE_FUNCTION */

    j = newtrack;
    if (j == CDROM_LEADOUT)  j = 0;

    if (j == 0)
    {
        k = 27;
    }
    else
    {
        k = j * 10 + 37;
    } // ENDIF- Where to start hunting for this number?

    if (cdvdtd != NULL)
    {
        cdvdtd->type = tocbuffer[j*10 + 30];

        temptime[0] = BCDTOHEX(tocbuffer[k]);
        temptime[1] = BCDTOHEX(tocbuffer[k + 1]);
        temptime[2] = BCDTOHEX(tocbuffer[k + 2]);
        cdvdtd->lsn = MSFtoLBA(temptime);
    } // ENDIF- Does the caller REALLY want this data?

    return(0); // Call accomplished
} // END CDVDgetTD()
Esempio n. 3
0
s32 CALLBACK CDVDgetTD(u8 track, cdvdTD *Buffer) {
  u8 actualtrack;
  int pos;
  char temptime[3];

#ifdef VERBOSE_FUNCTION_INTERFACE
  PrintLog("CDVDiso interface: CDVDgetTD()");
#endif /* VERBOSE_FUNCTION_INTERFACE */

  if(isofile == NULL)  return(-1);
  if(deviceopencount > 0) {
    deviceopencount--;
    if(deviceopencount > 0)  return(-1);
  } // ENDIF- Still simulating device tray open?

  actualtrack = track;
  if(actualtrack == 0xaa)  actualtrack = 0;

  if((isofile->cdvdtype == CDVD_TYPE_PS2DVD) ||
     (isofile->cdvdtype == CDVD_TYPE_DVDV)) {
    if (actualtrack <= 1) {
      Buffer->type = 0;
      Buffer->lsn = isofile->filesectorsize;
    } else {
      Buffer->type = CDVD_MODE1_TRACK;
      Buffer->lsn = 0;
    } // ENDIF- Whole disc? (or single track?)
  } else {
    if (actualtrack == 0) {
      Buffer->type = 0;
      temptime[0] = BCDTOHEX(isofile->toc[27]);
      temptime[1] = BCDTOHEX(isofile->toc[28]);
      temptime[2] = BCDTOHEX(isofile->toc[29]);
      Buffer->lsn = MSFtoLBA(temptime);
    } else {
      pos = actualtrack * 10;
      pos += 30;
      Buffer->type = isofile->toc[pos];
      temptime[0] = BCDTOHEX(isofile->toc[pos + 7]);
      temptime[1] = BCDTOHEX(isofile->toc[pos + 8]);
      temptime[2] = BCDTOHEX(isofile->toc[pos + 9]);
      Buffer->lsn = MSFtoLBA(temptime);
    } // ENDIF- Whole disc? (or single track?)
  } // ENDIF- Retrieve track info from a DVD? (or a CD?)

  return(0);
} // END CDVDgetTD()
Esempio n. 4
0
File: toc.c Progetto: Aced14/pcsx2
extern int IsoSaveTOC(struct IsoFile *isofile)
{
	char tocext[] = ".toc\0";
	char tocheader[] = "TOC1\0";
	ACTUALHANDLE tochandle;
	char tocname[256];
	int i;
	int j;
	int retval;
	unsigned char cdvdtype;
	struct tocTN toctn;
	struct tocTD toctd;
	char temptime[3];
	if (isofile == NULL)  return(-1);
	i = 0;
	while ((i < 256) && (isofile->name[i] != 0))
	{
		tocname[i] = isofile->name[i];
		i++;
	} // ENDWHILE- Copying the data name to the toc name
	j = 0;
	while ((i < 256) && (tocext[j] != 0))
	{
		tocname[i] = tocext[j];
		i++;
		j++;
	} // ENDWHILE- Append ".toc" to end of name
	tocname[i] = 0; // And 0-terminate

	ActualFileDelete(tocname);
	tochandle = ActualFileOpenForWrite(tocname);
	if (tochandle == ACTUALHANDLENULL)  return(-1);

	retval = ActualFileWrite(tochandle, 4, tocheader);
	if (retval < 4)
	{
		ActualFileClose(tochandle);
		tochandle = ACTUALHANDLENULL;
		ActualFileDelete(tocname);
		return(-1);
	} // ENDIF- Trouble writing to the 'toc' file?

	cdvdtype = isofile->cdvdtype;
	ActualFileWrite(tochandle, 1, (char *) &cdvdtype);
	if ((cdvdtype != CDVD_TYPE_PS2DVD) && (cdvdtype != CDVD_TYPE_DVDV))
	{
		toctn.strack = BCDTOHEX(isofile->toc[7]);
		toctn.etrack = BCDTOHEX(isofile->toc[17]);
		ActualFileWrite(tochandle, sizeof(struct tocTN), (char *) &toctn);
		// Leadout Data
		toctd.type = 0;
		temptime[0] = BCDTOHEX(isofile->toc[27]);
		temptime[1] = BCDTOHEX(isofile->toc[28]);
		temptime[2] = BCDTOHEX(isofile->toc[29]);
		toctd.lsn = MSFtoLBA(temptime);
		ActualFileWrite(tochandle, sizeof(struct tocTD), (char *) &toctd);
		for (i = toctn.strack; i <= toctn.etrack; i++)
		{
			j = i * 10 + 30;
			toctd.type = isofile->toc[j];
			temptime[0] = BCDTOHEX(isofile->toc[j + 7]);
			temptime[1] = BCDTOHEX(isofile->toc[j + 8]);
			temptime[2] = BCDTOHEX(isofile->toc[j + 9]);
			toctd.lsn = MSFtoLBA(temptime);
			ActualFileWrite(tochandle, sizeof(struct tocTD), (char *) &toctd);
		} // NEXT i- write out each track
	} // ENDIF- Not a DVD? (Then output CD track data)
	ActualFileClose(tochandle);
	tochandle = ACTUALHANDLENULL;
	return(0);
} // END IsoSaveTOC()