Ejemplo n.º 1
0
bool CDIF_DumpCD(const char *fn)
{
 FILE *fp;

 if(!(fp = fopen(fn, "wb")))
 {
  ErrnoHolder ene(errno);

  printf("File open error: %s\n", ene.StrError());
  return(0);
 }

 for(long long i = 0; i < toc.tracks[100].lba; i++)
 {
  uint8 buf[2352 + 96];

  CDIF_ReadRawSector(buf, i);

  if(fwrite(buf, 1, 2352 + 96, fp) != 2352 + 96)
  {
   ErrnoHolder ene(errno);

   printf("File write error: %s\n", ene.StrError());
  }
 }

 if(fclose(fp))
 {
  ErrnoHolder ene(errno);

  printf("fclose error: %s\n", ene.StrError());
 }

 return(1);
}
Ejemplo n.º 2
0
	static bool								ModuleTestMagic			()
	{
		//TODO: Does this work in all cases?
		uint8_t Buffer[4000];
		CDIF_ReadRawSector(Buffer, 4);
		return Buffer[56] == 'S' && Buffer[57] == 'o' && Buffer[58] == 'n' && Buffer[59] == 'y';
	}
Ejemplo n.º 3
0
int CDIF_ReadSector(uint8* pBuf, uint32 lba, uint32 nSectors)
{
 int ret = 0;

 while(nSectors--)
 {
  uint8 tmpbuf[2352 + 96];

  if(!CDIF_ReadRawSector(tmpbuf, lba))
  {
   puts("CDIF Raw Read error");
   return(FALSE);
  }

  if(!CDIF_ValidateRawSector(tmpbuf))
  {
   MDFN_DispMessage(_("Uncorrectable data at sector %d"), lba);
   MDFN_PrintError(_("Uncorrectable data at sector %d"), lba);
   return(false);
  }

  const int mode = tmpbuf[12 + 3];

  if(!ret)
   ret = mode;

  if(mode == 1)
  {
   memcpy(pBuf, &tmpbuf[12 + 4], 2048);
  }
  else if(mode == 2)
  {
   memcpy(pBuf, &tmpbuf[12 + 4 + 8], 2048);
  }
  else
  {
   printf("CDIF_ReadSector() invalid sector type at LBA=%u\n", (unsigned int)lba);
   return(false);
  }

  pBuf += 2048;
  lba++;
 }

 return(ret);
}