Exemplo n.º 1
0
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode) {
  s32 s32result;

#ifdef VERBOSE_FUNCTION
  PrintLog("CDVD interface: CDVDreadTrack(%i)", lsn);
#endif /* VERBOSE_FUNCTION */

  s32result = 0;
  errno = 0;

  if(DiscInserted() == -1)  return(-1);

  if(userbuffer < BUFFERMAX) {
    if((bufferlist[userbuffer].lsn == lsn) &&
       (bufferlist[userbuffer].mode == mode)) {
      return(0);
    } // ENDIF- And it's the right one?
  } // ENDIF- Are we already pointing at the buffer?

  userbuffer = FindListBuffer(lsn);
  if(userbuffer < BUFFERMAX) {
    if((bufferlist[userbuffer].lsn == lsn) &&
       (bufferlist[userbuffer].mode == mode)) {
      return(0);
    } // ENDIF- And it was the right one?
  } // ENDIF- Was a buffer found in the cache?

  replacebuffer++;
  if(replacebuffer >= BUFFERMAX)  replacebuffer = 0;
  userbuffer = replacebuffer;

  if(bufferlist[replacebuffer].upsort != 0xffff) {
    RemoveListBuffer(replacebuffer);
  } // ENDIF- Reference already in place? Remove it.

  s32result = DeviceReadTrack(lsn, mode, bufferlist[replacebuffer].buffer);
  bufferlist[replacebuffer].lsn = lsn;
  bufferlist[replacebuffer].mode = mode;
  bufferlist[replacebuffer].offset = DeviceBufferOffset();

  if((s32result != 0) || (errno != 0)) {
    bufferlist[replacebuffer].mode = -1; // Error! flag buffer as such.
  } else {
    if((disctype != CDVD_TYPE_PS2DVD) && (disctype != CDVD_TYPE_DVDV)) {
      if(mode == CDVD_MODE_2352) {
        CDreadSubQ(lsn, &bufferlist[replacebuffer].subq);
        errno = 0;
      } // ENDIF- Read subq as well?
    } // ENDIF- Read a DVD buffer or a CD buffer?
  } // ENDIF-Read ok? Fill out rest of buffer info.
  AddListBuffer(replacebuffer);
  return(s32result);
} // END CDVDreadTrack()
Exemplo n.º 2
0
gint DeviceBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
	char templine[256];
	u8 tempbuffer[2352];
	struct IsoFile *tofile;
	const char *tempdevice;
	s32 retval;
	cdvdTD cdvdtd;
	int stop;
	int compressmethod;
	int multi;
	int imagetype;
	int i;
	DeviceBoxUnfocus();
	tempdevice = gtk_entry_get_text(GTK_ENTRY(devicebox.device));
	strcpy(conf.devicename, tempdevice); // Temporarily put in new device name
	tempdevice = NULL;
	retval = DeviceOpen();
	if (retval != 0) {
		DeviceClose();
		MessageBoxShow("Could not open the device", 2);
		return (TRUE);
	} // ENDIF- Trouble opening device? Abort here.
	DeviceTrayStatus();
	retval = DiscInserted();
	if (retval != 0) {
		DeviceClose();
		MessageBoxShow("No disc in the device\r\nPlease put a disc in and try again.", 2);
		return (TRUE);
	} // ENDIF- Trouble opening device? Abort here.
	retval = DeviceGetTD(0, &cdvdtd); // Fish for Ending Sector
	if (retval < 0) {
		DeviceClose();
		MessageBoxShow("Could not retrieve disc sector size", 2);
		return (TRUE);
	} // ENDIF- Trouble getting disc sector count?
	compressmethod = gtk_combo_box_get_active(GTK_COMBO_BOX(devicebox.compress));
	if (compressmethod > 0)  compressmethod += 2;
	multi = 0;
	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(devicebox.multi)) == TRUE)
		multi = 1;
	imagetype = 0;
	if ((disctype != CDVD_TYPE_PS2DVD) &&
	    (disctype != CDVD_TYPE_DVDV))  imagetype = 8;
	tofile = IsoFileOpenForWrite(gtk_entry_get_text(GTK_ENTRY(devicebox.file)),
	                             imagetype,
	                             multi,
	                             compressmethod);
	if (tofile == NULL) {
		DeviceClose();
		MessageBoxShow("Could not create the new ISO file", 2);
		return (TRUE);
	} // ENDIF- Trouble opening the ISO file?
	// Open Progress Bar
	sprintf(templine, "%s -> %s",
	        gtk_entry_get_text(GTK_ENTRY(devicebox.device)), tofile->name);
	ProgressBoxStart(templine, (off64_t) cdvdtd.lsn);
	tofile->cdvdtype = disctype;
	for (i = 0; i < 2048; i++)  tofile->toc[i] = tocbuffer[i];
	stop = 0;
	mainbox.stop = 0;
	progressbox.stop = 0;
	while ((stop == 0) && (tofile->sectorpos < cdvdtd.lsn)) {
		if (imagetype == 0) {
			retval = DeviceReadTrack((u32) tofile->sectorpos,
			                         CDVD_MODE_2048,
			                         tempbuffer);
		} else {
			retval = DeviceReadTrack((u32) tofile->sectorpos,
			                         CDVD_MODE_2352,
			                         tempbuffer);
		} // ENDIF- Are we reading a DVD sector? (Or a CD sector?)
		if (retval < 0) {
			for (i = 0; i < 2352; i++)
				tempbuffer[i] = 0; // NEXT i- Zeroing the buffer
		} // ENDIF- Trouble reading next block?
		retval = IsoFileWrite(tofile, tempbuffer);
		if (retval < 0) {
			MessageBoxShow("Trouble writing new file", 3);
			stop = 1;
		} // ENDIF- Trouble writing out the next block?
		ProgressBoxTick(tofile->sectorpos);
		while (gtk_events_pending())  gtk_main_iteration();
		if (mainbox.stop != 0)  stop = 2;
		if (progressbox.stop != 0)  stop = 2;
	} // ENDWHILE- No reason found to stop...
	ProgressBoxStop();
	if (stop == 0) {
		if (tofile->multi == 1)  tofile->name[tofile->multipos] = '0'; // First file
		strcpy(templine, tofile->name);
	} // ENDIF- Did we succeed with the transfer?
	DeviceClose();
	if (stop == 0) {
		IsoSaveTOC(tofile);
		tofile = IsoFileClose(tofile);
		gtk_entry_set_text(GTK_ENTRY(mainbox.file), templine);
	} else
		tofile = IsoFileCloseAndDelete(tofile); // ENDIF- (Failed to complete writing file? Get rid of the garbage files.)
	if (stop != 1)  DeviceBoxRefocus();
	if (stop == 0)  DeviceBoxCancelEvent(widget, event, data);
	return (TRUE);
} // END DeviceBoxOKEvent()
Exemplo n.º 3
0
void DeviceBoxOKEvent() {

  char templine[256];

  u8 tempbuffer[2352];

  struct IsoFile *tofile;

  s32 retval;

  cdvdTD cdvdtd;

  int stop;

  HWND tempitem;

  int compressmethod;

  int multi;

  int imagetype;

  int i;



  DeviceBoxUnfocus();



  GetDlgItemText(deviceboxwindow, IDC_0302, conf.devicename, 256);

  retval = DeviceOpen();

  if(retval != 0) {

    DeviceClose();

    DeviceBoxRefocus();

    MessageBox(deviceboxwindow,

               "Could not open the device",

               "CDVDisoEFP Message",

               MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);

    return;

  } // ENDIF- Trouble opening device? Abort here.



  DeviceTrayStatus();

  retval = DiscInserted();

  if(retval != 0) {

    DeviceClose();

    DeviceBoxRefocus();

    MessageBox(deviceboxwindow,

               "No disc in the device\r\nPlease put a disc in and try again.",

               "CDVDisoEFP Message",

               MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);

    return;

  } // ENDIF- Trouble opening device? Abort here.



  retval = DeviceGetTD(0, &cdvdtd); // Fish for Ending Sector

  if(retval < 0) {

    DeviceClose();

    DeviceBoxRefocus();

    MessageBox(deviceboxwindow,

               "Could not retrieve disc sector size",

               "CDVDisoEFP Message",

               MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);

    return;

  } // ENDIF- Trouble getting disc sector count?



  tempitem = GetDlgItem(deviceboxwindow, IDC_0309);

  compressmethod = ComboBox_GetCurSel(tempitem);

  tempitem = NULL;

  if(compressmethod > 0)  compressmethod += 2;



  multi = 0;

  if(IsDlgButtonChecked(deviceboxwindow, IDC_0311))  multi = 1;



  imagetype = 0;

  if((disctype != CDVD_TYPE_PS2DVD) &&

     (disctype != CDVD_TYPE_DVDV))  imagetype = 8;



  GetDlgItemText(deviceboxwindow, IDC_0305, templine, 256);

  tofile = IsoFileOpenForWrite(templine,

                               imagetype,

                               multi,

                               compressmethod);

  if(tofile == NULL) {

    DeviceClose();

    DeviceBoxRefocus();

    MessageBox(deviceboxwindow,

               "Could not create the new ISO file",

               "CDVDisoEFP Message",

               MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);

    return;

  } // ENDIF- Trouble opening the ISO file?



  // Open Progress Bar

  sprintf(templine, "%s -> %s", conf.devicename, tofile->name);

  ProgressBoxStart(templine, (off64_t) cdvdtd.lsn);



  tofile->cdvdtype = disctype;

  for(i = 0; i < 2048; i++)  tofile->toc[i] = tocbuffer[i];



  stop = 0;

  mainboxstop = 0;

  progressboxstop = 0;

  while((stop == 0) && (tofile->sectorpos < cdvdtd.lsn)) {

    if(imagetype == 0) {

      retval = DeviceReadTrack((u32) tofile->sectorpos,

                               CDVD_MODE_2048,

                               tempbuffer);

    } else {

      retval = DeviceReadTrack((u32) tofile->sectorpos,

                               CDVD_MODE_2352,

                               tempbuffer);

    } // ENDIF- Are we reading a DVD sector? (Or a CD sector?)

    if(retval < 0) {

      for(i = 0; i < 2352; i++) {

        tempbuffer[i] = 0;

      } // NEXT i- Zeroing the buffer

    } // ENDIF- Trouble reading next block?

    retval = IsoFileWrite(tofile, tempbuffer);

    if(retval < 0) {

      MessageBox(deviceboxwindow,

                 "Trouble writing new file",

                 "CDVDisoEFP Message",

                 MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);

      stop = 1;

    } // ENDIF- Trouble writing out the next block?



    ProgressBoxTick(tofile->sectorpos);



    if(mainboxstop != 0)  stop = 2;

    if(progressboxstop != 0)  stop = 2;

  } // ENDWHILE- No reason found to stop...



  ProgressBoxStop();



  if(stop == 0) {

    if(tofile->multi == 1)  tofile->name[tofile->multipos] = '0'; // First file

    strcpy(templine, tofile->name);

  } // ENDIF- Did we succeed with the transfer?



  DeviceClose();

  if(stop == 0) {

    IsoSaveTOC(tofile);

    tofile = IsoFileClose(tofile);

    SetDlgItemText(mainboxwindow, IDC_0202, templine);

  } else {

    tofile = IsoFileCloseAndDelete(tofile);

  } // ENDIF- (Failed to complete writing file? Get rid of the garbage files.)



  DeviceBoxRefocus();

  if(stop == 0)  DeviceBoxCancelEvent();

  return;

} // END DeviceBoxOKEvent()