CDVDisoEFP: I'm not sure what happened in the mists of time to this folder that caused all the source code in it to have the lines all become double-spaced and unreadable... Got rid of all the extra blank lines, and reformated.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@559 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-02-21 10:36:02 +00:00
parent 34a0b82986
commit 18917ebc21
89 changed files with 12252 additions and 25466 deletions

View File

@ -1,734 +1,401 @@
/* CD.c /* CD.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <errno.h> // errno #include <errno.h> // errno
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <string.h> // strerror() #include <string.h> // strerror()
#include <fcntl.h> // open() #include <fcntl.h> // open()
#include <sys/ioctl.h> // ioctl() #include <sys/ioctl.h> // ioctl()
#include <sys/stat.h> // open() #include <sys/stat.h> // open()
#include <sys/types.h> // lseek(), open() #include <sys/types.h> // lseek(), open()
#include <unistd.h> // close(), lseek(), (sleep()) #include <unistd.h> // close(), lseek(), (sleep())
#include <linux/cdrom.h> // CD/DVD based ioctl() and defines. #include <linux/cdrom.h> // CD/DVD based ioctl() and defines.
#include "../convert.h" #include "../convert.h"
#include "logfile.h" #include "logfile.h"
#include "device.h" #include "device.h"
#include "CD.h" #include "CD.h"
// Constants // Constants
u8 *playstationcdname = "PLAYSTATION\0"; u8 *playstationcdname = "PLAYSTATION\0";
u8 *ps1name = "CD-XA001\0"; u8 *ps1name = "CD-XA001\0";
// CD-ROM temp storage structures (see linux/cdrom.h for details) // CD-ROM temp storage structures (see linux/cdrom.h for details)
struct cdrom_tochdr cdheader; struct cdrom_tochdr cdheader;
struct cdrom_tocentry cdtrack; struct cdrom_tocentry cdtrack;
struct cdrom_subchnl subchannel; struct cdrom_subchnl subchannel;
u8 cdtempbuffer[2352]; u8 cdtempbuffer[2352];
int cdmode; // mode of last CDVDreadTrack call (important for CDs) int cdmode; // mode of last CDVDreadTrack call (important for CDs)
// Internal Functions // Internal Functions
void InitCDSectorInfo()
{
void InitCDSectorInfo() {
cdmode = -1; cdmode = -1;
} // END InitSectorInfo(); } // END InitSectorInfo();
// Function Calls from CDVD.c // Function Calls from CDVD.c
void InitCDInfo()
{
void InitCDInfo() {
InitCDSectorInfo(); InitCDSectorInfo();
} // END InitDiscType() } // END InitDiscType()
s32 CDreadTrack(u32 lsn, int mode, u8 *buffer)
{
s32 CDreadTrack(u32 lsn, int mode, u8 *buffer) {
s32 s32result; s32 s32result;
#ifdef VERBOSE_FUNCTION #ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: CDreadTrack(%i)", lsn); PrintLog("CDVD driver: CDreadTrack(%i)", lsn);
#endif /* VERBOSE_FUNCTION */ #endif /* VERBOSE_FUNCTION */
s32result = 0; s32result = 0;
if (buffer == NULL) return(-1); if (buffer == NULL) return(-1);
// The CD way of figuring out where to read. // The CD way of figuring out where to read.
LBAtoMSF(lsn, buffer); LBAtoMSF(lsn, buffer);
switch (mode)
{
switch(mode) {
case CDVD_MODE_2048: case CDVD_MODE_2048:
case CDVD_MODE_2328: case CDVD_MODE_2328:
case CDVD_MODE_2340: case CDVD_MODE_2340:
case CDVD_MODE_2352: case CDVD_MODE_2352:
errno = 4; // Interrupted system call... (simulated the first time) errno = 4; // Interrupted system call... (simulated the first time)
while (errno == 4)
while(errno == 4) { {
errno = 0; errno = 0;
s32result = ioctl(devicehandle, CDROMREADRAW, buffer); s32result = ioctl(devicehandle, CDROMREADRAW, buffer);
} // ENDWHILE- Continually being interrupted by the system... } // ENDWHILE- Continually being interrupted by the system...
break; break;
case CDVD_MODE_2368: // Unimplemented... as yet. case CDVD_MODE_2368: // Unimplemented... as yet.
default: default:
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: Unknown Mode %i", mode); PrintLog("CDVD driver: Unknown Mode %i", mode);
#endif /* VERBOSE_WARNINGS */ #endif /* VERBOSE_WARNINGS */
return(-1); // Illegal Read Mode? Abort return(-1); // Illegal Read Mode? Abort
break; break;
} // ENDSWITCH- Which read mode should we choose? } // ENDSWITCH- Which read mode should we choose?
if ((s32result == -1) || (errno != 0))
if((s32result == -1) || (errno != 0)) { {
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: Error reading CD: %i:%s", errno, strerror(errno)); PrintLog("CDVD driver: Error reading CD: %i:%s", errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */ #endif /* VERBOSE_WARNINGS */
InitCDSectorInfo(); InitCDSectorInfo();
return(-1); return(-1);
} // ENDIF- Trouble getting a track count? } // ENDIF- Trouble getting a track count?
cdmode = mode; // Save mode for buffer positioning later. cdmode = mode; // Save mode for buffer positioning later.
return(0); // Call accomplished return(0); // Call accomplished
} // END CDreadTrack() } // END CDreadTrack()
s32 CDgetBufferOffset()
{
s32 CDgetBufferOffset() {
#ifdef VERBOSE_FUNCTION #ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: CDgetBufferOffset()"); PrintLog("CDVD driver: CDgetBufferOffset()");
#endif /* VERBOSE_FUNCTION */ #endif /* VERBOSE_FUNCTION */
switch (cdmode)
{
switch(cdmode) {
case CDVD_MODE_2048: case CDVD_MODE_2048:
return(0 + 24); return(0 + 24);
case CDVD_MODE_2328: case CDVD_MODE_2328:
return(0 + 24); return(0 + 24);
case CDVD_MODE_2340: case CDVD_MODE_2340:
return(0 + 12); return(0 + 12);
case CDVD_MODE_2352: case CDVD_MODE_2352:
return(0 + 0); return(0 + 0);
case CDVD_MODE_2368: // Unimplemented... as yet. case CDVD_MODE_2368: // Unimplemented... as yet.
default: default:
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: Unknown Mode %i", cdmode); PrintLog("CDVD driver: Unknown Mode %i", cdmode);
#endif /* VERBOSE_WARNINGS */ #endif /* VERBOSE_WARNINGS */
return(0); // Not to worry. for now. return(0); // Not to worry. for now.
} // ENDSWITCH- where should we put the buffer pointer? } // ENDSWITCH- where should we put the buffer pointer?
} // END CDgetBuffer() } // END CDgetBuffer()
// I, personally, don't see the big deal with SubQ // I, personally, don't see the big deal with SubQ
// However, sooner or later I'll incorporate it into the Cache Buffer system // However, sooner or later I'll incorporate it into the Cache Buffer system
// (backward compatibility, and all that) // (backward compatibility, and all that)
s32 CDreadSubQ(u32 lsn, cdvdSubQ *subq)
s32 CDreadSubQ(u32 lsn, cdvdSubQ *subq) { {
int tempmode; int tempmode;
s32 s32result; s32 s32result;
s32result = 0; s32result = 0;
#ifdef VERBOSE_FUNCTION #ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: CDreadSubQ()"); PrintLog("CDVD driver: CDreadSubQ()");
#endif /* VERBOSE_FUNCTION */ #endif /* VERBOSE_FUNCTION */
tempmode = cdmode; tempmode = cdmode;
if (tempmode == -1) tempmode = CDVD_MODE_2352; if (tempmode == -1) tempmode = CDVD_MODE_2352;
CDreadTrack(lsn, tempmode, cdtempbuffer); CDreadTrack(lsn, tempmode, cdtempbuffer);
if ((s32result == -1) || (errno != 0))
if((s32result == -1) || (errno != 0)) { {
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: Error prepping CD SubQ: %i:%s", errno, strerror(errno)); PrintLog("CDVD driver: Error prepping CD SubQ: %i:%s", errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */ #endif /* VERBOSE_WARNINGS */
return(s32result); return(s32result);
} // ENDIF- Trouble? } // ENDIF- Trouble?
subchannel.cdsc_format = CDROM_MSF; subchannel.cdsc_format = CDROM_MSF;
s32result = ioctl(devicehandle, CDROMSUBCHNL, &subchannel); s32result = ioctl(devicehandle, CDROMSUBCHNL, &subchannel);
if ((s32result == -1) || (errno != 0))
if((s32result == -1) || (errno != 0)) { {
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: Error reading CD SubQ: %i:%s", errno, strerror(errno)); PrintLog("CDVD driver: Error reading CD SubQ: %i:%s", errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */ #endif /* VERBOSE_WARNINGS */
return(s32result); return(s32result);
} // ENDIF- Trouble? } // ENDIF- Trouble?
if (subq != NULL)
{
if(subq != NULL) {
subq->mode = subchannel.cdsc_adr; subq->mode = subchannel.cdsc_adr;
subq->ctrl = subchannel.cdsc_ctrl; subq->ctrl = subchannel.cdsc_ctrl;
subq->trackNum = subchannel.cdsc_trk; subq->trackNum = subchannel.cdsc_trk;
subq->trackIndex = subchannel.cdsc_ind; subq->trackIndex = subchannel.cdsc_ind;
subq->trackM = subchannel.cdsc_reladdr.msf.minute; subq->trackM = subchannel.cdsc_reladdr.msf.minute;
subq->trackS = subchannel.cdsc_reladdr.msf.second; subq->trackS = subchannel.cdsc_reladdr.msf.second;
subq->trackF = subchannel.cdsc_reladdr.msf.frame; subq->trackF = subchannel.cdsc_reladdr.msf.frame;
subq->discM = subchannel.cdsc_absaddr.msf.minute; subq->discM = subchannel.cdsc_absaddr.msf.minute;
subq->discS = subchannel.cdsc_absaddr.msf.second; subq->discS = subchannel.cdsc_absaddr.msf.second;
subq->discF = subchannel.cdsc_absaddr.msf.frame; subq->discF = subchannel.cdsc_absaddr.msf.frame;
} // ENDIF- Did the caller want all this data? } // ENDIF- Did the caller want all this data?
return(0); return(0);
} // END CDVDreadSubQ() } // END CDVDreadSubQ()
s32 CDgetTN(cdvdTN *cdvdtn)
{
s32 CDgetTN(cdvdTN *cdvdtn) {
#ifdef VERBOSE_FUNCTION #ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: CDgetTN()"); PrintLog("CDVD driver: CDgetTN()");
#endif /* VERBOSE_FUNCTION */ #endif /* VERBOSE_FUNCTION */
if (cdvdtn != NULL)
{
if(cdvdtn != NULL) {
cdvdtn->strack = cdheader.cdth_trk0; cdvdtn->strack = cdheader.cdth_trk0;
cdvdtn->etrack = cdheader.cdth_trk1; cdvdtn->etrack = cdheader.cdth_trk1;
} // ENDIF- programmer actually WANTS this info? } // ENDIF- programmer actually WANTS this info?
return(0); // Call accomplished return(0); // Call accomplished
} // END CDVDgetTN() } // END CDVDgetTN()
s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd)
{
s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd) {
u8 j; u8 j;
u16 k; u16 k;
char temptime[3]; char temptime[3];
#ifdef VERBOSE_FUNCTION #ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: CDgetTD()"); PrintLog("CDVD driver: CDgetTD()");
#endif /* VERBOSE_FUNCTION */ #endif /* VERBOSE_FUNCTION */
j = newtrack; j = newtrack;
if (j == CDROM_LEADOUT) j = 0; if (j == CDROM_LEADOUT) j = 0;
if (j == 0)
{
if(j == 0) {
k = 27; k = 27;
}
} else { else
{
k = j * 10 + 37; k = j * 10 + 37;
} // ENDIF- Where to start hunting for this number? } // ENDIF- Where to start hunting for this number?
if (cdvdtd != NULL)
{
if(cdvdtd != NULL) {
cdvdtd->type = tocbuffer[j*10 + 30]; cdvdtd->type = tocbuffer[j*10 + 30];
temptime[0] = BCDTOHEX(tocbuffer[k]); temptime[0] = BCDTOHEX(tocbuffer[k]);
temptime[1] = BCDTOHEX(tocbuffer[k + 1]); temptime[1] = BCDTOHEX(tocbuffer[k + 1]);
temptime[2] = BCDTOHEX(tocbuffer[k + 2]); temptime[2] = BCDTOHEX(tocbuffer[k + 2]);
cdvdtd->lsn = MSFtoLBA(temptime); cdvdtd->lsn = MSFtoLBA(temptime);
} // ENDIF- Does the caller REALLY want this data? } // ENDIF- Does the caller REALLY want this data?
return(0); // Call accomplished return(0); // Call accomplished
} // END CDVDgetTD() } // END CDVDgetTD()
s32 CALLBACK CDgetDiskType(s32 ioctldisktype)
{
s32 CALLBACK CDgetDiskType(s32 ioctldisktype) {
s32 offset; s32 offset;
s32 s32result; s32 s32result;
int i; int i;
u8 j; u8 j;
int tempdisctype; int tempdisctype;
offset = 0; offset = 0;
errno = 0; errno = 0;
i = 0; i = 0;
j = 0; j = 0;
tempdisctype = CDVD_TYPE_UNKNOWN; tempdisctype = CDVD_TYPE_UNKNOWN;
#ifdef VERBOSE_FUNCTION #ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: CDgetDiskType()"); PrintLog("CDVD driver: CDgetDiskType()");
#endif /* VERBOSE_FUNCTION */ #endif /* VERBOSE_FUNCTION */
s32result = CDreadTrack(16, CDVD_MODE_2352, cdtempbuffer); s32result = CDreadTrack(16, CDVD_MODE_2352, cdtempbuffer);
if ((s32result != 0) || (errno != 0))
if((s32result != 0) || (errno != 0)) { {
return(-1); return(-1);
} // ENDIF- Cannot read the CD's ISO9660 volume sector? Abort } // ENDIF- Cannot read the CD's ISO9660 volume sector? Abort
disctype = CDVD_TYPE_DETCTCD; disctype = CDVD_TYPE_DETCTCD;
switch (ioctldisktype)
{
switch(ioctldisktype) {
case CDS_AUDIO: case CDS_AUDIO:
#ifdef VERBOSE_DISC_TYPE #ifdef VERBOSE_DISC_TYPE
PrintLog("CDVD driver: Detected CDDA Audio disc."); PrintLog("CDVD driver: Detected CDDA Audio disc.");
#endif /* VERBOSE_DISC_TYPE */ #endif /* VERBOSE_DISC_TYPE */
tempdisctype = CDVD_TYPE_CDDA; tempdisctype = CDVD_TYPE_CDDA;
tocbuffer[0] = 0x01; tocbuffer[0] = 0x01;
break; break;
case CDS_DATA_1: case CDS_DATA_1:
case CDS_MIXED: case CDS_MIXED:
#ifdef VERBOSE_DISC_TYPE #ifdef VERBOSE_DISC_TYPE
PrintLog("CDVD driver: Detected CD disc."); PrintLog("CDVD driver: Detected CD disc.");
#endif /* VERBOSE_DISC_TYPE */ #endif /* VERBOSE_DISC_TYPE */
tocbuffer[0] = 0x41; tocbuffer[0] = 0x41;
CDreadTrack(16, CDVD_MODE_2048, cdtempbuffer); CDreadTrack(16, CDVD_MODE_2048, cdtempbuffer);
offset = CDgetBufferOffset(); offset = CDgetBufferOffset();
i = 0; i = 0;
while ((*(playstationcdname + i) != 0) && while ((*(playstationcdname + i) != 0) &&
(*(playstationcdname + i) == cdtempbuffer[offset + 8 + i])) i++; (*(playstationcdname + i) == cdtempbuffer[offset + 8 + i])) i++;
if (*(playstationcdname + i) == 0)
if(*(playstationcdname + i) == 0) { {
i = 0; i = 0;
while ((*(ps1name + i) != 0) && while ((*(ps1name + i) != 0) &&
(*(ps1name + i) == cdtempbuffer[offset + 1024 + i])) i++; (*(ps1name + i) == cdtempbuffer[offset + 1024 + i])) i++;
if (*(ps1name + i) == 0)
if(*(ps1name + i) == 0) { {
#ifdef VERBOSE_DISC_TYPE #ifdef VERBOSE_DISC_TYPE
PrintLog("CDVD driver: Detected Playstation CD disc."); PrintLog("CDVD driver: Detected Playstation CD disc.");
#endif /* VERBOSE_DISC_TYPE */ #endif /* VERBOSE_DISC_TYPE */
tempdisctype = CDVD_TYPE_PSCD; tempdisctype = CDVD_TYPE_PSCD;
}
} else { else
{
#ifdef VERBOSE_DISC_TYPE #ifdef VERBOSE_DISC_TYPE
PrintLog("CDVD driver: Detected Playstation 2 CD disc."); PrintLog("CDVD driver: Detected Playstation 2 CD disc.");
#endif /* VERBOSE_DISC_TYPE */ #endif /* VERBOSE_DISC_TYPE */
tempdisctype = CDVD_TYPE_PS2CD; tempdisctype = CDVD_TYPE_PS2CD;
} // ENDIF- Did we find the CD ident? (For Playstation 1 CDs) } // ENDIF- Did we find the CD ident? (For Playstation 1 CDs)
}
} else { else
{
tempdisctype = CDVD_TYPE_UNKNOWN; tempdisctype = CDVD_TYPE_UNKNOWN;
} // ENDIF- Did we find the Playstation name? } // ENDIF- Did we find the Playstation name?
break; break;
default: default:
return(-1); return(-1);
} // ENDSWITCH- What has ioctl disc type come up with? } // ENDSWITCH- What has ioctl disc type come up with?
// Collect TN data // Collect TN data
cdheader.cdth_trk0 = 0; cdheader.cdth_trk0 = 0;
cdheader.cdth_trk1 = 0; cdheader.cdth_trk1 = 0;
s32result = ioctl(devicehandle, CDROMREADTOCHDR, &cdheader); s32result = ioctl(devicehandle, CDROMREADTOCHDR, &cdheader);
if ((s32result == -1) || (errno != 0))
if((s32result == -1) || (errno != 0)) { {
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: Error reading TN: (%i) %i:%s", PrintLog("CDVD driver: Error reading TN: (%i) %i:%s",
s32result, errno, strerror(errno)); s32result, errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */ #endif /* VERBOSE_WARNINGS */
cdheader.cdth_trk0 = 1; cdheader.cdth_trk0 = 1;
cdheader.cdth_trk1 = 1; cdheader.cdth_trk1 = 1;
} // ENDIF- Failed to read in track count? Assume 1 track. } // ENDIF- Failed to read in track count? Assume 1 track.
#ifdef VERBOSE_DISC_INFO #ifdef VERBOSE_DISC_INFO
PrintLog("CDVD driver: Track Number Range: %i-%i", PrintLog("CDVD driver: Track Number Range: %i-%i",
cdheader.cdth_trk0, cdheader.cdth_trk1); cdheader.cdth_trk0, cdheader.cdth_trk1);
#endif /* VERBOSE_DISC_INFO */ #endif /* VERBOSE_DISC_INFO */
tocbuffer[2] = 0xA0; tocbuffer[2] = 0xA0;
tocbuffer[7] = HEXTOBCD(cdheader.cdth_trk0); tocbuffer[7] = HEXTOBCD(cdheader.cdth_trk0);
tocbuffer[12] = 0xA1; tocbuffer[12] = 0xA1;
tocbuffer[17] = HEXTOBCD(cdheader.cdth_trk1); tocbuffer[17] = HEXTOBCD(cdheader.cdth_trk1);
// Collect disc TD data // Collect disc TD data
cdtrack.cdte_track = CDROM_LEADOUT; cdtrack.cdte_track = CDROM_LEADOUT;
cdtrack.cdte_format = CDROM_LBA; cdtrack.cdte_format = CDROM_LBA;
s32result = ioctl(devicehandle, CDROMREADTOCENTRY, &cdtrack); s32result = ioctl(devicehandle, CDROMREADTOCENTRY, &cdtrack);
if ((s32result == -1) || (errno != 0))
if((s32result == -1) || (errno != 0)) { {
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: Error reading TD for disc: (%i) %i:%s", PrintLog("CDVD driver: Error reading TD for disc: (%i) %i:%s",
s32result, errno, strerror(errno)); s32result, errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */ #endif /* VERBOSE_WARNINGS */
return(-1); return(-1);
} // ENDIF- Trouble getting a track count? } // ENDIF- Trouble getting a track count?
LBAtoMSF(cdtrack.cdte_addr.lba, &tocbuffer[27]); LBAtoMSF(cdtrack.cdte_addr.lba, &tocbuffer[27]);
#ifdef VERBOSE_DISC_INFO #ifdef VERBOSE_DISC_INFO
PrintLog("CDVD driver: Total Time: %i:%i", PrintLog("CDVD driver: Total Time: %i:%i",
tocbuffer[27], tocbuffer[28]); tocbuffer[27], tocbuffer[28]);
#endif /* VERBOSE_DISC_INFO */ #endif /* VERBOSE_DISC_INFO */
tocbuffer[27] = HEXTOBCD(tocbuffer[27]); tocbuffer[27] = HEXTOBCD(tocbuffer[27]);
tocbuffer[28] = HEXTOBCD(tocbuffer[28]); tocbuffer[28] = HEXTOBCD(tocbuffer[28]);
tocbuffer[29] = HEXTOBCD(tocbuffer[29]); tocbuffer[29] = HEXTOBCD(tocbuffer[29]);
// Collect track TD data // Collect track TD data
for (j = cdheader.cdth_trk0; j <= cdheader.cdth_trk1; j++)
for(j = cdheader.cdth_trk0; j <= cdheader.cdth_trk1; j++) { {
cdtrack.cdte_track = j; // j-1? cdtrack.cdte_track = j; // j-1?
cdtrack.cdte_format = CDROM_LBA; cdtrack.cdte_format = CDROM_LBA;
s32result = ioctl(devicehandle, CDROMREADTOCENTRY, &cdtrack); s32result = ioctl(devicehandle, CDROMREADTOCENTRY, &cdtrack);
if ((s32result == -1) || (errno != 0))
if((s32result == -1) || (errno != 0)) { {
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: Error reading TD for track %i: (%i) %i:%s", PrintLog("CDVD driver: Error reading TD for track %i: (%i) %i:%s",
j, s32result, errno, strerror(errno)); j, s32result, errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */ #endif /* VERBOSE_WARNINGS */
// No more here... // No more here...
}
else
} else { {
LBAtoMSF(cdtrack.cdte_addr.lba, &tocbuffer[j*10 + 37]); LBAtoMSF(cdtrack.cdte_addr.lba, &tocbuffer[j*10 + 37]);
#ifdef VERBOSE_DISC_INFO #ifdef VERBOSE_DISC_INFO
PrintLog("CDVD driver: Track %i: Data Mode %i Disc Start Time:%i:%i.%i\n", PrintLog("CDVD driver: Track %i: Data Mode %i Disc Start Time:%i:%i.%i\n",
j, j,
cdtrack.cdte_datamode, cdtrack.cdte_datamode,
tocbuffer[j*10+37], tocbuffer[j*10+37],
tocbuffer[j*10+38], tocbuffer[j*10+38],
tocbuffer[j*10+39]); tocbuffer[j*10+39]);
#endif /* VERBOSE_DISC_INFO */ #endif /* VERBOSE_DISC_INFO */
tocbuffer[j*10 + 30] = cdtrack.cdte_datamode; tocbuffer[j*10 + 30] = cdtrack.cdte_datamode;
tocbuffer[j*10 + 32] = HEXTOBCD(j); tocbuffer[j*10 + 32] = HEXTOBCD(j);
tocbuffer[j*10 + 37] = HEXTOBCD(tocbuffer[j*10 + 37]); tocbuffer[j*10 + 37] = HEXTOBCD(tocbuffer[j*10 + 37]);
tocbuffer[j*10 + 38] = HEXTOBCD(tocbuffer[j*10 + 38]); tocbuffer[j*10 + 38] = HEXTOBCD(tocbuffer[j*10 + 38]);
tocbuffer[j*10 + 39] = HEXTOBCD(tocbuffer[j*10 + 39]); tocbuffer[j*10 + 39] = HEXTOBCD(tocbuffer[j*10 + 39]);
} // ENDIF- Trouble getting a track count? } // ENDIF- Trouble getting a track count?
} // NEXT j- Reading each track's info in turn } // NEXT j- Reading each track's info in turn
errno = 0; errno = 0;
disctype = tempdisctype; // Trigger the fact we have the info (finally) disctype = tempdisctype; // Trigger the fact we have the info (finally)
return(disctype); return(disctype);
} // END CDVDgetDiskType() } // END CDVDgetDiskType()

View File

@ -1,92 +1,40 @@
/* CD.h /* CD.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef __CD_H__ #ifndef __CD_H__
#define __CD_H__ #define __CD_H__
#ifndef __LINUX__ #ifndef __LINUX__
#ifdef __linux__ #ifdef __linux__
#define __LINUX__ #define __LINUX__
#endif /* __linux__ */ #endif /* __linux__ */
#endif /* No __LINUX__ */ #endif /* No __LINUX__ */
#define CDVDdefs #define CDVDdefs
#include "../PS2Edefs.h" #include "../PS2Edefs.h"
// Exported Functions // Exported Functions
extern void InitCDInfo(); extern void InitCDInfo();
extern s32 CDreadTrack(u32 lsn, int mode, u8 *buffer); extern s32 CDreadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 CDgetBufferOffset(); extern s32 CDgetBufferOffset();
extern s32 CDreadSubQ(u32 lsn, cdvdSubQ *subq); extern s32 CDreadSubQ(u32 lsn, cdvdSubQ *subq);
extern s32 CDgetTN(cdvdTN *cdvdtn); extern s32 CDgetTN(cdvdTN *cdvdtn);
extern s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd); extern s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd);
extern s32 CDgetDiskType(s32 ioctldisktype); extern s32 CDgetDiskType(s32 ioctldisktype);
#endif /* __CD_H__ */ #endif /* __CD_H__ */

View File

@ -17,10 +17,7 @@
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#ifndef __LINUX__ #ifndef __LINUX__
#ifdef __linux__ #ifdef __linux__
#define __LINUX__ #define __LINUX__
@ -28,7 +25,6 @@
#endif /* No __LINUX__ */ #endif /* No __LINUX__ */
#define CDVDdefs #define CDVDdefs
#include "PS2Edefs.h" #include "PS2Edefs.h"
#include "conf.h" #include "conf.h"
#include "actualfile.h" #include "actualfile.h"
#include "isofile.h" #include "isofile.h"
@ -36,31 +32,25 @@
#include "convert.h" #include "convert.h"
#include "version.h" #include "version.h"
#include "CDVDiso.h" #include "CDVDiso.h"
struct IsoFile *isofile; struct IsoFile *isofile;
char isobuffer[2448]; char isobuffer[2448];
char isocdcheck[2448]; char isocdcheck[2448];
int isomode; int isomode;
int deviceopencount; // 0 = Closed, 1+ = Open int deviceopencount; // 0 = Closed, 1+ = Open
char* CALLBACK PS2EgetLibName()
{
char* CALLBACK PS2EgetLibName() {
return(libname); return(libname);
} // END PS2EgetLibName() } // END PS2EgetLibName()
u32 CALLBACK PS2EgetLibType()
{
u32 CALLBACK PS2EgetLibType() {
return(PS2E_LT_CDVD); return(PS2E_LT_CDVD);
} // END PS2getLibType() } // END PS2getLibType()
u32 CALLBACK PS2EgetLibVersion2(u32 type)
{
u32 CALLBACK PS2EgetLibVersion2(u32 type) {
return((version << 16) | (revision << 8) | build); return((version << 16) | (revision << 8) | build);
} }
s32 CALLBACK CDVDinit()
{
s32 CALLBACK CDVDinit() {
int i; int i;
InitLog(); InitLog();
@ -69,9 +59,7 @@ s32 CALLBACK CDVDinit() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDinit()"); PrintLog("CDVDiso interface: CDVDinit()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
InitConf(); InitConf();
isofile = NULL; isofile = NULL;
isomode = -1; isomode = -1;
for (i = 0; i < 2048; i++) isocdcheck[i] = 0; for (i = 0; i < 2048; i++) isocdcheck[i] = 0;
@ -79,39 +67,33 @@ s32 CALLBACK CDVDinit() {
return(0); return(0);
} // END CDVDinit() } // END CDVDinit()
void CALLBACK CDVDshutdown()
{
void CALLBACK CDVDshutdown() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDshutdown()"); PrintLog("CDVDiso interface: CDVDshutdown()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
isofile = IsoFileClose(isofile); isofile = IsoFileClose(isofile);
CloseLog(); CloseLog();
} // END CDVDshutdown() } // END CDVDshutdown()
s32 CALLBACK CDVDopen(const char* pTitleFilename)
{
s32 CALLBACK CDVDopen(const char* pTitleFilename) {
int retval; int retval;
int i; int i;
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDopen()"); PrintLog("CDVDiso interface: CDVDopen()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
LoadConf(); LoadConf();
if (pTitleFilename != NULL) strcpy(conf.isoname, pTitleFilename); if (pTitleFilename != NULL) strcpy(conf.isoname, pTitleFilename);
if ((conf.isoname[0] == 0) || if ((conf.isoname[0] == 0) ||
((conf.startconfigure != 0) && (deviceopencount == 0)) || ((conf.startconfigure != 0) && (deviceopencount == 0)) ||
((conf.restartconfigure != 0) && (deviceopencount > 0))) { ((conf.restartconfigure != 0) && (deviceopencount > 0)))
{
ExecCfg("configure"); ExecCfg("configure");
LoadConf(); LoadConf();
} // ENDIF- Haven't initialized the configure program yet? Do so now. } // ENDIF- Haven't initialized the configure program yet? Do so now.
isofile = IsoFileOpenForRead(conf.isoname); isofile = IsoFileOpenForRead(conf.isoname);
if(isofile == NULL) { if (isofile == NULL)
{
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: Failed to open ISO file!"); PrintLog("CDVDiso interface: Failed to open ISO file!");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
@ -119,25 +101,22 @@ s32 CALLBACK CDVDopen(const char* pTitleFilename) {
for (i = 0; i < 2048; i++) isocdcheck[i] = 0; for (i = 0; i < 2048; i++) isocdcheck[i] = 0;
return(0); return(0);
} // ENDIF- Trouble opening file? Abort. } // ENDIF- Trouble opening file? Abort.
retval = IsoFileSeek(isofile, 16); retval = IsoFileSeek(isofile, 16);
if (retval != 0) return(-1); if (retval != 0) return(-1);
retval = IsoFileRead(isofile, isobuffer); retval = IsoFileRead(isofile, isobuffer);
if (retval != 0) return(-1); if (retval != 0) return(-1);
if (deviceopencount > 0)
if(deviceopencount > 0) { {
i = 0; i = 0;
while ((i < 2048) && (isocdcheck[i] == isobuffer[i])) i++; while ((i < 2048) && (isocdcheck[i] == isobuffer[i])) i++;
if (i == 2048) deviceopencount = 0; // Same CD/DVD? No delay. if (i == 2048) deviceopencount = 0; // Same CD/DVD? No delay.
} // ENDIF- Is this a restart? Check for disc change. } // ENDIF- Is this a restart? Check for disc change.
for (i = 0; i < 2048; i++) isocdcheck[i] = isobuffer[i]; for (i = 0; i < 2048; i++) isocdcheck[i] = isobuffer[i];
return(0); return(0);
} // END CDVDopen() } // END CDVDopen()
void CALLBACK CDVDclose()
void CALLBACK CDVDclose() { {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDclose()"); PrintLog("CDVDiso interface: CDVDclose()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
@ -145,25 +124,22 @@ void CALLBACK CDVDclose() {
deviceopencount = 50; deviceopencount = 50;
} // END CDVDclose() } // END CDVDclose()
s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq)
s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) { {
char temptime[3]; char temptime[3];
int i; int i;
int pos; int pos;
u32 tracklsn; u32 tracklsn;
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDreadSubQ()"); PrintLog("CDVDiso interface: CDVDreadSubQ()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if (isofile == NULL) return(-1); if (isofile == NULL) return(-1);
if (deviceopencount > 0) return(-1); if (deviceopencount > 0) return(-1);
if ((isofile->cdvdtype == CDVD_TYPE_PS2DVD) || if ((isofile->cdvdtype == CDVD_TYPE_PS2DVD) ||
(isofile->cdvdtype == CDVD_TYPE_DVDV)) { (isofile->cdvdtype == CDVD_TYPE_DVDV))
{
return(-1); // DVDs don't have SubQ data return(-1); // DVDs don't have SubQ data
} // ENDIF- Trying to get a SubQ from a DVD? } // ENDIF- Trying to get a SubQ from a DVD?
// fake it // fake it
i = BCDTOHEX(isofile->toc[7]); i = BCDTOHEX(isofile->toc[7]);
pos = i * 10; pos = i * 10;
@ -172,7 +148,8 @@ s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) {
temptime[1] = BCDTOHEX(isofile->toc[pos + 8]); temptime[1] = BCDTOHEX(isofile->toc[pos + 8]);
temptime[2] = BCDTOHEX(isofile->toc[pos + 9]); temptime[2] = BCDTOHEX(isofile->toc[pos + 9]);
tracklsn = MSFtoLBA(temptime); tracklsn = MSFtoLBA(temptime);
while((i < BCDTOHEX(isofile->toc[17])) && (tracklsn < lsn)) { while ((i < BCDTOHEX(isofile->toc[17])) && (tracklsn < lsn))
{
i++; i++;
pos = i * 10; pos = i * 10;
pos += 30; pos += 30;
@ -203,61 +180,65 @@ s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) {
return(0); return(0);
} // END CDVDreadSubQ() } // END CDVDreadSubQ()
s32 CALLBACK CDVDgetTN(cdvdTN *Buffer)
{
s32 CALLBACK CDVDgetTN(cdvdTN *Buffer) {
if (isofile == NULL) return(-1); if (isofile == NULL) return(-1);
if (deviceopencount > 0) return(-1); if (deviceopencount > 0) return(-1);
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDgetTN()"); PrintLog("CDVDiso interface: CDVDgetTN()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if ((isofile->cdvdtype == CDVD_TYPE_PS2DVD) || if ((isofile->cdvdtype == CDVD_TYPE_PS2DVD) ||
(isofile->cdvdtype == CDVD_TYPE_DVDV)) { (isofile->cdvdtype == CDVD_TYPE_DVDV))
{
Buffer->strack = 1; Buffer->strack = 1;
Buffer->etrack = 1; Buffer->etrack = 1;
} else { }
else
{
Buffer->strack = BCDTOHEX(isofile->toc[7]); Buffer->strack = BCDTOHEX(isofile->toc[7]);
Buffer->etrack = BCDTOHEX(isofile->toc[17]); Buffer->etrack = BCDTOHEX(isofile->toc[17]);
} // ENDIF- Retrieve track info from a DVD? (or a CD?) } // ENDIF- Retrieve track info from a DVD? (or a CD?)
return(0); return(0);
} // END CDVDgetTN() } // END CDVDgetTN()
s32 CALLBACK CDVDgetTD(u8 track, cdvdTD *Buffer)
s32 CALLBACK CDVDgetTD(u8 track, cdvdTD *Buffer) { {
u8 actualtrack; u8 actualtrack;
int pos; int pos;
char temptime[3]; char temptime[3];
if (isofile == NULL) return(-1); if (isofile == NULL) return(-1);
if (deviceopencount > 0) return(-1); if (deviceopencount > 0) return(-1);
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDgetTD()"); PrintLog("CDVDiso interface: CDVDgetTD()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
actualtrack = track; actualtrack = track;
if (actualtrack == 0xaa) actualtrack = 0; if (actualtrack == 0xaa) actualtrack = 0;
if ((isofile->cdvdtype == CDVD_TYPE_PS2DVD) || if ((isofile->cdvdtype == CDVD_TYPE_PS2DVD) ||
(isofile->cdvdtype == CDVD_TYPE_DVDV)) { (isofile->cdvdtype == CDVD_TYPE_DVDV))
if (actualtrack <= 1) { {
if (actualtrack <= 1)
{
Buffer->type = 0; Buffer->type = 0;
Buffer->lsn = isofile->filesectorsize; Buffer->lsn = isofile->filesectorsize;
} else { }
else
{
Buffer->type = CDVD_MODE1_TRACK; Buffer->type = CDVD_MODE1_TRACK;
Buffer->lsn = 0; Buffer->lsn = 0;
} // ENDIF- Whole disc? (or single track?) } // ENDIF- Whole disc? (or single track?)
} else { }
if (actualtrack == 0) { else
{
if (actualtrack == 0)
{
Buffer->type = 0; Buffer->type = 0;
temptime[0] = BCDTOHEX(isofile->toc[27]); temptime[0] = BCDTOHEX(isofile->toc[27]);
temptime[1] = BCDTOHEX(isofile->toc[28]); temptime[1] = BCDTOHEX(isofile->toc[28]);
temptime[2] = BCDTOHEX(isofile->toc[29]); temptime[2] = BCDTOHEX(isofile->toc[29]);
Buffer->lsn = MSFtoLBA(temptime); Buffer->lsn = MSFtoLBA(temptime);
} else { }
else
{
pos = actualtrack * 10; pos = actualtrack * 10;
pos += 30; pos += 30;
Buffer->type = isofile->toc[pos]; Buffer->type = isofile->toc[pos];
@ -267,71 +248,64 @@ s32 CALLBACK CDVDgetTD(u8 track, cdvdTD *Buffer) {
Buffer->lsn = MSFtoLBA(temptime); Buffer->lsn = MSFtoLBA(temptime);
} // ENDIF- Whole disc? (or single track?) } // ENDIF- Whole disc? (or single track?)
} // ENDIF- Retrieve track info from a DVD? (or a CD?) } // ENDIF- Retrieve track info from a DVD? (or a CD?)
return(0); return(0);
} // END CDVDgetTD() } // END CDVDgetTD()
s32 CALLBACK CDVDgetTOC(void* toc)
s32 CALLBACK CDVDgetTOC(void* toc) { {
int i; int i;
if (isofile == NULL) return(-1); if (isofile == NULL) return(-1);
if (deviceopencount > 0) return(-1); if (deviceopencount > 0) return(-1);
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDgetTOC()"); PrintLog("CDVDiso interface: CDVDgetTOC()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
for (i = 0; i < 2048; i++) *(((char *) toc) + i) = isofile->toc[i]; for (i = 0; i < 2048; i++) *(((char *) toc) + i) = isofile->toc[i];
return(0); return(0);
} // END CDVDgetTOC() } // END CDVDgetTOC()
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode)
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode) { {
int retval; int retval;
if (isofile == NULL) return(-1); if (isofile == NULL) return(-1);
if(deviceopencount > 0) { if (deviceopencount > 0)
{
deviceopencount--; deviceopencount--;
return(-1); return(-1);
} // ENDIF- Simulate a temporarily open device? } // ENDIF- Simulate a temporarily open device?
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDreadTrack(%u)", lsn); PrintLog("CDVDiso interface: CDVDreadTrack(%u)", lsn);
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
retval = IsoFileSeek(isofile, (off64_t) lsn); retval = IsoFileSeek(isofile, (off64_t) lsn);
if(retval != 0) { if (retval != 0)
{
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: Trouble finding the sector!"); PrintLog("CDVDiso interface: Trouble finding the sector!");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
return(-1); return(-1);
} // ENDIF- Trouble finding the sector? } // ENDIF- Trouble finding the sector?
retval = IsoFileRead(isofile, isobuffer); retval = IsoFileRead(isofile, isobuffer);
if(retval != 0) { if (retval != 0)
{
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: Trouble reading the sector!"); PrintLog("CDVDiso interface: Trouble reading the sector!");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
return(-1); return(-1);
} // ENDIF- Trouble finding the sector? } // ENDIF- Trouble finding the sector?
isomode = mode; isomode = mode;
return(0); return(0);
} // END CDVDreadTrack() } // END CDVDreadTrack()
u8* CALLBACK CDVDgetBuffer()
u8* CALLBACK CDVDgetBuffer() { {
int offset; int offset;
if (isofile == NULL) return(NULL); if (isofile == NULL) return(NULL);
if (deviceopencount > 0) return(NULL); if (deviceopencount > 0) return(NULL);
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDgetBuffer()"); PrintLog("CDVDiso interface: CDVDgetBuffer()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
offset = 0; offset = 0;
switch(isomode) { switch (isomode)
{
case CDVD_MODE_2352: case CDVD_MODE_2352:
offset = 0; offset = 0;
break; break;
@ -343,44 +317,39 @@ u8* CALLBACK CDVDgetBuffer() {
offset = 24; offset = 24;
break; break;
} // ENDSWITCH isomode- offset to where data it wants is. } // ENDSWITCH isomode- offset to where data it wants is.
if (offset > isofile->blockoffset) offset = isofile->blockoffset; if (offset > isofile->blockoffset) offset = isofile->blockoffset;
return(isobuffer + offset); return(isobuffer + offset);
} // END CDVDgetBuffer() } // END CDVDgetBuffer()
s32 CALLBACK CDVDgetDiskType()
{
s32 CALLBACK CDVDgetDiskType() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDgetDiskType()"); PrintLog("CDVDiso interface: CDVDgetDiskType()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if (isofile == NULL) return(CDVD_TYPE_NODISC); if (isofile == NULL) return(CDVD_TYPE_NODISC);
if(deviceopencount > 0) { if (deviceopencount > 0)
{
deviceopencount--; deviceopencount--;
return(CDVD_TYPE_DETCT); return(CDVD_TYPE_DETCT);
} // ENDIF- Simulate a temporarily open device? } // ENDIF- Simulate a temporarily open device?
return(isofile->cdvdtype); return(isofile->cdvdtype);
} // END CDVDgetDiskType() } // END CDVDgetDiskType()
s32 CALLBACK CDVDgetTrayStatus()
{
s32 CALLBACK CDVDgetTrayStatus() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDgetTrayStatus()"); PrintLog("CDVDiso interface: CDVDgetTrayStatus()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if (isofile == NULL) return(CDVD_TRAY_OPEN); if (isofile == NULL) return(CDVD_TRAY_OPEN);
if(deviceopencount > 30) { if (deviceopencount > 30)
{
deviceopencount--; deviceopencount--;
return(CDVD_TRAY_OPEN); return(CDVD_TRAY_OPEN);
} // ENDIF- Simulate a temporarily open device? } // ENDIF- Simulate a temporarily open device?
return(CDVD_TRAY_CLOSE); return(CDVD_TRAY_CLOSE);
} // END CDVDgetTrayStatus() } // END CDVDgetTrayStatus()
s32 CALLBACK CDVDctrlTrayOpen()
{
s32 CALLBACK CDVDctrlTrayOpen() {
int i; int i;
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
@ -393,44 +362,41 @@ s32 CALLBACK CDVDctrlTrayOpen() {
// and re-Open() // and re-Open()
if ((conf.isoname[0] == 0) || if ((conf.isoname[0] == 0) ||
((conf.restartconfigure != 0) && (deviceopencount > 0))) { ((conf.restartconfigure != 0) && (deviceopencount > 0)))
{
ExecCfg("configure"); ExecCfg("configure");
LoadConf(); LoadConf();
} // ENDIF- Haven't initialized the configure program yet? Do so now. } // ENDIF- Haven't initialized the configure program yet? Do so now.
isofile = IsoFileOpenForRead(conf.isoname); isofile = IsoFileOpenForRead(conf.isoname);
if(isofile == NULL) { if (isofile == NULL)
{
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: Failed to open ISO file!"); PrintLog("CDVDiso interface: Failed to open ISO file!");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
} // ENDIF- Trouble opening file? Abort. } // ENDIF- Trouble opening file? Abort.
if (deviceopencount > 0)
if(deviceopencount > 0) { {
i = 0; i = 0;
while ((i < 2048) && (isocdcheck[i] == isobuffer[i])) i++; while ((i < 2048) && (isocdcheck[i] == isobuffer[i])) i++;
if (i == 2048) deviceopencount = 0; // Same CD/DVD? No delay. if (i == 2048) deviceopencount = 0; // Same CD/DVD? No delay.
} // ENDIF- Is this a restart? Check for disc change. } // ENDIF- Is this a restart? Check for disc change.
for (i = 0; i < 2048; i++) isocdcheck[i] = isobuffer[i]; for (i = 0; i < 2048; i++) isocdcheck[i] = isobuffer[i];
return(0); return(0);
} // END CDVDctrlTrayOpen() } // END CDVDctrlTrayOpen()
s32 CALLBACK CDVDctrlTrayClose()
s32 CALLBACK CDVDctrlTrayClose() { {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDctrlTrayClose()"); PrintLog("CDVDiso interface: CDVDctrlTrayClose()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
return(0); return(0);
} // END CDVDctrlTrayClose() } // END CDVDctrlTrayClose()
void CALLBACK CDVDconfigure()
{
void CALLBACK CDVDconfigure() {
ExecCfg("configure"); ExecCfg("configure");
} // END CDVDconfigure() } // END CDVDconfigure()
s32 CALLBACK CDVDtest()
{
s32 CALLBACK CDVDtest() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDtest()"); PrintLog("CDVDiso interface: CDVDtest()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
@ -443,8 +409,7 @@ s32 CALLBACK CDVDtest() {
// Note really need this? Why not just return(0)... // Note really need this? Why not just return(0)...
} // END CDVDtest() } // END CDVDtest()
void CALLBACK CDVDabout()
void CALLBACK CDVDabout() { {
ExecCfg("about"); ExecCfg("about");
} // END CDVDabout() } // END CDVDabout()

View File

@ -1,58 +1,26 @@
/* CDVDiso.h /* CDVDiso.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef CDVDISO_H #ifndef CDVDISO_H
#define CDVDISO_H #define CDVDISO_H
// #define VERBOSE_FUNCTION_INTERFACE // #define VERBOSE_FUNCTION_INTERFACE
#endif /* CDVDISO_H */ #endif /* CDVDISO_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,90 +1,39 @@
/* DVD.h /* DVD.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef __DVD_H__ #ifndef __DVD_H__
#define __DVD_H__ #define __DVD_H__
#ifndef __LINUX__ #ifndef __LINUX__
#ifdef __linux__ #ifdef __linux__
#define __LINUX__ #define __LINUX__
#endif /* __linux__ */ #endif /* __linux__ */
#endif /* No __LINUX__ */ #endif /* No __LINUX__ */
#define CDVDdefs #define CDVDdefs
#include "PS2Edefs.h" #include "PS2Edefs.h"
// Exported Functions // Exported Functions
extern void HexDump(u8 *strptr, u8 count); extern void HexDump(u8 *strptr, u8 count);
extern void InitDVDInfo(); extern void InitDVDInfo();
extern s32 DVDreadTrack(u32 lsn, int mode, u8 *buffer); extern s32 DVDreadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 DVDgetTN(cdvdTN *cdvdtn); extern s32 DVDgetTN(cdvdTN *cdvdtn);
extern s32 DVDgetTD(u8 newtrack, cdvdTD *cdvdtd); extern s32 DVDgetTD(u8 newtrack, cdvdTD *cdvdtd);
extern s32 DVDgetDiskType(s32 ioctldisktype); extern s32 DVDgetDiskType(s32 ioctldisktype);
#endif /* __DVD_H__ */ #endif /* __DVD_H__ */

View File

@ -1,212 +1,109 @@
/* aboutbox.c /* aboutbox.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <gtk/gtkbutton.h> // gtk_button_new_with_label() #include <gtk/gtkbutton.h> // gtk_button_new_with_label()
#include <gtk/gtkcontainer.h> // gtk_container_add() #include <gtk/gtkcontainer.h> // gtk_container_add()
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new() #include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
#include <gtk/gtklabel.h> // gtk_label_new() #include <gtk/gtklabel.h> // gtk_label_new()
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit() #include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
#include <gtk/gtkvbox.h> // gtk_vbox_new() #include <gtk/gtkvbox.h> // gtk_vbox_new()
#include <gtk/gtkwindow.h> // gtk_window_new() #include <gtk/gtkwindow.h> // gtk_window_new()
#include "version.h" #include "version.h"
#include "aboutbox.h" #include "aboutbox.h"
struct AboutBoxData aboutbox; struct AboutBoxData aboutbox;
gint AboutBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
if (aboutbox.window != NULL)
gint AboutBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) { {
if(aboutbox.window != NULL) {
gtk_widget_destroy(aboutbox.window); gtk_widget_destroy(aboutbox.window);
aboutbox.window = NULL; aboutbox.window = NULL;
} // ENDIF- Do we have an About Box still? } // ENDIF- Do we have an About Box still?
gtk_main_quit(); gtk_main_quit();
return(TRUE); return(TRUE);
} // END AboutBoxCancelEvent() } // END AboutBoxCancelEvent()
void AboutBoxDisplay()
{
void AboutBoxDisplay() {
GtkWidget *item; GtkWidget *item;
GtkWidget *container; GtkWidget *container;
GtkWidget *vbox1; GtkWidget *vbox1;
char templine[256]; char templine[256];
aboutbox.window = NULL; aboutbox.window = NULL;
aboutbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); aboutbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(aboutbox.window), 5); gtk_container_set_border_width(GTK_CONTAINER(aboutbox.window), 5);
gtk_window_set_title(GTK_WINDOW(aboutbox.window), "About CDVDisoEFP"); gtk_window_set_title(GTK_WINDOW(aboutbox.window), "About CDVDisoEFP");
gtk_window_set_position(GTK_WINDOW(aboutbox.window), GTK_WIN_POS_CENTER); gtk_window_set_position(GTK_WINDOW(aboutbox.window), GTK_WIN_POS_CENTER);
gtk_window_set_modal(GTK_WINDOW(aboutbox.window), TRUE); gtk_window_set_modal(GTK_WINDOW(aboutbox.window), TRUE);
gtk_window_set_resizable(GTK_WINDOW(aboutbox.window), FALSE); gtk_window_set_resizable(GTK_WINDOW(aboutbox.window), FALSE);
g_signal_connect(G_OBJECT(aboutbox.window), "delete_event", g_signal_connect(G_OBJECT(aboutbox.window), "delete_event",
G_CALLBACK(AboutBoxCancelEvent), NULL); G_CALLBACK(AboutBoxCancelEvent), NULL);
vbox1 = gtk_vbox_new(FALSE, 5); vbox1 = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(aboutbox.window), vbox1); gtk_container_add(GTK_CONTAINER(aboutbox.window), vbox1);
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5); gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
gtk_widget_show(vbox1); gtk_widget_show(vbox1);
sprintf(templine, "%s v%i.%i", libname, revision, build); sprintf(templine, "%s v%i.%i", libname, revision, build);
item = gtk_label_new(templine); item = gtk_label_new(templine);
gtk_box_pack_start(GTK_BOX(vbox1), item, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
item = gtk_label_new("Current Author: efp"); item = gtk_label_new("Current Author: efp");
gtk_box_pack_start(GTK_BOX(vbox1), item, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
item = gtk_label_new("Original code by: linuzappz & shadow"); item = gtk_label_new("Original code by: linuzappz & shadow");
gtk_box_pack_start(GTK_BOX(vbox1), item, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
container = gtk_hbutton_box_new(); container = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(vbox1), container, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), container, TRUE, TRUE, 0);
gtk_widget_show(container); gtk_widget_show(container);
item = gtk_button_new_with_label("Ok"); item = gtk_button_new_with_label("Ok");
gtk_container_add(GTK_CONTAINER(container), item); gtk_container_add(GTK_CONTAINER(container), item);
GTK_WIDGET_SET_FLAGS(item, GTK_CAN_DEFAULT); GTK_WIDGET_SET_FLAGS(item, GTK_CAN_DEFAULT);
gtk_widget_show(item); gtk_widget_show(item);
g_signal_connect(G_OBJECT(item), "clicked", g_signal_connect(G_OBJECT(item), "clicked",
G_CALLBACK(AboutBoxCancelEvent), NULL); G_CALLBACK(AboutBoxCancelEvent), NULL);
item = NULL; item = NULL;
container = NULL; container = NULL;
vbox1 = NULL; vbox1 = NULL;
gtk_widget_show(aboutbox.window); gtk_widget_show(aboutbox.window);
gtk_main(); gtk_main();
} // END AboutDisplay() } // END AboutDisplay()

View File

@ -1,78 +1,34 @@
/* aboutbox.h /* aboutbox.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef ABOUTBOX_H #ifndef ABOUTBOX_H
#define ABOUTBOX_H #define ABOUTBOX_H
#include <gtk/gtkwidget.h> #include <gtk/gtkwidget.h>
struct AboutBoxData
{
struct AboutBoxData {
GtkWidget *window; // GtkWindow - About Box GtkWidget *window; // GtkWindow - About Box
}; };
extern struct AboutBoxData aboutbox; extern struct AboutBoxData aboutbox;
extern void AboutBoxDisplay(); extern void AboutBoxDisplay();
#endif /* ABOUTBOX_H */ #endif /* ABOUTBOX_H */

View File

@ -1,444 +1,238 @@
/* actualfile.c /* actualfile.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <errno.h> // errno #include <errno.h> // errno
#include <fcntl.h> // open() #include <fcntl.h> // open()
#include <stdio.h> // rename() #include <stdio.h> // rename()
#include <string.h> // strerror() #include <string.h> // strerror()
#include <sys/stat.h> // stat64(), open(), fstat() #include <sys/stat.h> // stat64(), open(), fstat()
#include <sys/types.h> // stat64(), open(), fstat(), lseek64() #include <sys/types.h> // stat64(), open(), fstat(), lseek64()
#include <unistd.h> // stat64(), fstat(), lseek64(), read(), close(), write() #include <unistd.h> // stat64(), fstat(), lseek64(), read(), close(), write()
// unlink() // unlink()
#include "logfile.h" #include "logfile.h"
#include "actualfile.h" #include "actualfile.h"
int IsActualFile(const char *filename)
{
int IsActualFile(const char *filename) {
int retval; int retval;
struct stat64 filestat; struct stat64 filestat;
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: IsActualFile(%s)", filename); PrintLog("CDVDiso file: IsActualFile(%s)", filename);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
errno = 0; errno = 0;
retval = stat64(filename, &filestat); retval = stat64(filename, &filestat);
if ((retval < 0) || (errno != 0))
if((retval < 0) || (errno != 0)) { {
#ifdef VERBOSE_WARNING_ACTUALFILE #ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Error retrieving stats on %s", filename); PrintLog("CDVDiso file: Error retrieving stats on %s", filename);
PrintLog("CDVDiso file: %i:%s\n", errno, strerror(errno)); PrintLog("CDVDiso file: %i:%s\n", errno, strerror(errno));
#endif /* VERBOSE_WARNING_ACTUALFILE */ #endif /* VERBOSE_WARNING_ACTUALFILE */
return(-1); // Name doesn't exist. return(-1); // Name doesn't exist.
} // ENDIF- Trouble getting stat on a file? } // ENDIF- Trouble getting stat on a file?
if (S_ISREG(filestat.st_mode) == 0) return(-2); // Not a regular file. if (S_ISREG(filestat.st_mode) == 0) return(-2); // Not a regular file.
return(0); // Yep, that's a file. return(0); // Yep, that's a file.
} // END IsActualFile() } // END IsActualFile()
void ActualFileDelete(const char *filename)
{
void ActualFileDelete(const char *filename) {
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileDelete(%s)", filename); PrintLog("CDVDiso file: ActualFileDelete(%s)", filename);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
unlink(filename); unlink(filename);
} // END ActualFileDelete() } // END ActualFileDelete()
void ActualFileRename(const char *origname, const char *newname)
{
void ActualFileRename(const char *origname, const char *newname) {
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileRename(%s->%s)", origname, newname); PrintLog("CDVDiso file: ActualFileRename(%s->%s)", origname, newname);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
rename(origname, newname); rename(origname, newname);
return; return;
} // END ActualFileRename() } // END ActualFileRename()
ACTUALHANDLE ActualFileOpenForRead(const char *filename)
{
ACTUALHANDLE ActualFileOpenForRead(const char *filename) {
int newhandle; int newhandle;
if (filename == NULL) return(-1); if (filename == NULL) return(-1);
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileOpenForRead(%s)", filename); PrintLog("CDVDiso file: ActualFileOpenForRead(%s)", filename);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
errno = 0; errno = 0;
newhandle = open(filename, O_RDONLY | O_LARGEFILE); newhandle = open(filename, O_RDONLY | O_LARGEFILE);
if ((newhandle < 0) || (errno != 0))
if((newhandle < 0) || (errno != 0)) { {
#ifdef VERBOSE_WARNING_ACTUALFILE #ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Error opening file %s\n", filename); PrintLog("CDVDiso file: Error opening file %s\n", filename);
PrintLog("CDVDiso file: (%i) %i:%s\n", newhandle, errno, strerror(errno)); PrintLog("CDVDiso file: (%i) %i:%s\n", newhandle, errno, strerror(errno));
#endif /* VERBOSE_WARNING_ACTUALFILE */ #endif /* VERBOSE_WARNING_ACTUALFILE */
return(-1); return(-1);
} // ENDIF- Error? Abort } // ENDIF- Error? Abort
return(newhandle); return(newhandle);
} // END ActualFileOpenForRead() } // END ActualFileOpenForRead()
off64_t ActualFileSize(ACTUALHANDLE handle)
{
off64_t ActualFileSize(ACTUALHANDLE handle) {
int retval; int retval;
struct stat64 filestat; struct stat64 filestat;
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileSize()\n"); PrintLog("CDVDiso file: ActualFileSize()\n");
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
errno = 0; errno = 0;
retval = fstat64(handle, &filestat); retval = fstat64(handle, &filestat);
if ((retval < 0) || (errno != 0)) return(-1); // Name doesn't exist. if ((retval < 0) || (errno != 0)) return(-1); // Name doesn't exist.
return(filestat.st_size); return(filestat.st_size);
} // END ActualFileSize() } // END ActualFileSize()
int ActualFileSeek(ACTUALHANDLE handle, off64_t position)
{
int ActualFileSeek(ACTUALHANDLE handle, off64_t position) {
off64_t moved; off64_t moved;
if (handle < 0) return(-1); if (handle < 0) return(-1);
if (position < 0) return(-1); // Maybe... position = 0? if (position < 0) return(-1); // Maybe... position = 0?
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileSeek(%lli)", position); PrintLog("CDVDiso file: ActualFileSeek(%lli)", position);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
errno = 0; errno = 0;
moved = lseek64(handle, position, SEEK_SET); moved = lseek64(handle, position, SEEK_SET);
if (errno != 0)
if(errno != 0) { {
#ifdef VERBOSE_WARNING_ACTUALFILE #ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Error on seek (%lli)", position); PrintLog("CDVDiso file: Error on seek (%lli)", position);
PrintLog("CDVDiso file: %i:%s\n", errno, strerror(errno)); PrintLog("CDVDiso file: %i:%s\n", errno, strerror(errno));
#endif /* VERBOSE_WARNING_ACTUALFILE */ #endif /* VERBOSE_WARNING_ACTUALFILE */
return(-1); return(-1);
} // ENDIF- Error? Abort } // ENDIF- Error? Abort
return(0); return(0);
} // END ActualFileSeek() } // END ActualFileSeek()
int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer)
{
int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer) {
int retval; int retval;
if (handle == ACTUALHANDLENULL) return(-1); if (handle == ACTUALHANDLENULL) return(-1);
if (bytes < 1) return(-1); if (bytes < 1) return(-1);
if (buffer == NULL) return(-1); if (buffer == NULL) return(-1);
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileRead(%i)", bytes); PrintLog("CDVDiso file: ActualFileRead(%i)", bytes);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
errno = 0; errno = 0;
retval = read(handle, buffer, bytes); retval = read(handle, buffer, bytes);
if ((retval < 0) || (errno != 0))
if((retval < 0) || (errno != 0)) { {
#ifdef VERBOSE_WARNING_ACTUALFILE #ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Error reading from file!"); PrintLog("CDVDiso file: Error reading from file!");
PrintLog("CDVDiso file: %i:%s", errno, strerror(errno)); PrintLog("CDVDiso file: %i:%s", errno, strerror(errno));
#endif /* VERBOSE_WARNING_ACTUALFILE */ #endif /* VERBOSE_WARNING_ACTUALFILE */
// return(-1); // return(-1);
} // ENDIF- Error? Abort } // ENDIF- Error? Abort
return(retval); // Send back how many bytes read return(retval); // Send back how many bytes read
} // END ActualFileRead() } // END ActualFileRead()
void ActualFileClose(ACTUALHANDLE handle)
{
void ActualFileClose(ACTUALHANDLE handle) {
if (handle < 0) return; if (handle < 0) return;
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileClose()"); PrintLog("CDVDiso file: ActualFileClose()");
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
errno = 0; errno = 0;
close(handle); close(handle);
return; return;
} // END ActualFileClose() } // END ActualFileClose()
ACTUALHANDLE ActualFileOpenForWrite(const char *filename)
{
ACTUALHANDLE ActualFileOpenForWrite(const char *filename) {
int newhandle; int newhandle;
if (filename == NULL) return(-1); if (filename == NULL) return(-1);
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileOpenForWrite(%s)", filename); PrintLog("CDVDiso file: ActualFileOpenForWrite(%s)", filename);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
errno = 0; errno = 0;
newhandle = open(filename, O_WRONLY | O_CREAT | O_LARGEFILE, 0644); newhandle = open(filename, O_WRONLY | O_CREAT | O_LARGEFILE, 0644);
if ((newhandle < 0) || (errno != 0))
if((newhandle < 0) || (errno != 0)) { {
#ifdef VERBOSE_WARNING_ACTUALFILE #ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Error opening file %s", filename); PrintLog("CDVDiso file: Error opening file %s", filename);
PrintLog("CDVDiso file: (%i) %i:%s", newhandle, errno, strerror(errno)); PrintLog("CDVDiso file: (%i) %i:%s", newhandle, errno, strerror(errno));
#endif /* VERBOSE_WARNING_ACTUALFILE */ #endif /* VERBOSE_WARNING_ACTUALFILE */
return(-1); return(-1);
} // ENDIF- Error? Abort } // ENDIF- Error? Abort
return(newhandle); return(newhandle);
} // END ActualFileOpenForWrite() } // END ActualFileOpenForWrite()
int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer)
{
int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer) {
int retval; int retval;
if (handle < 0) return(-1); if (handle < 0) return(-1);
if (bytes < 1) return(-1); if (bytes < 1) return(-1);
if (buffer == NULL) return(-1); if (buffer == NULL) return(-1);
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileWrite(%i)", bytes); PrintLog("CDVDiso file: ActualFileWrite(%i)", bytes);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
errno = 0; errno = 0;
retval = write(handle, buffer, bytes); retval = write(handle, buffer, bytes);
if ((retval < 0) || (errno != 0))
if((retval < 0) || (errno != 0)) { {
#ifdef VERBOSE_WARNING_ACTUALFILE #ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Error writing to file!"); PrintLog("CDVDiso file: Error writing to file!");
PrintLog("CDVDiso file: %i:%s", errno, strerror(errno)); PrintLog("CDVDiso file: %i:%s", errno, strerror(errno));
#endif /* VERBOSE_WARNING_ACTUALFILE */ #endif /* VERBOSE_WARNING_ACTUALFILE */
// return(-1); // return(-1);
} // ENDIF- Error? Abort } // ENDIF- Error? Abort
return(retval); // Send back how many bytes written return(retval); // Send back how many bytes written
} // END ActualFileWrite() } // END ActualFileWrite()

View File

@ -1,100 +1,45 @@
/* actualfile.h /* actualfile.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef ACTUALFILE_H #ifndef ACTUALFILE_H
#define ACTUALFILE_H #define ACTUALFILE_H
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
#define ACTUALHANDLE int #define ACTUALHANDLE int
#define ACTUALHANDLENULL -1 #define ACTUALHANDLENULL -1
// #define VERBOSE_FUNCTION_ACTUALFILE // #define VERBOSE_FUNCTION_ACTUALFILE
// #define VERBOSE_WARNING_ACTUALFILE // #define VERBOSE_WARNING_ACTUALFILE
extern int IsActualFile(const char *filename); extern int IsActualFile(const char *filename);
extern void ActualFileDelete(const char *filename); extern void ActualFileDelete(const char *filename);
extern void ActualFileRename(const char *origname, const char *newname); extern void ActualFileRename(const char *origname, const char *newname);
extern ACTUALHANDLE ActualFileOpenForRead(const char *filename); extern ACTUALHANDLE ActualFileOpenForRead(const char *filename);
extern off64_t ActualFileSize(ACTUALHANDLE handle); extern off64_t ActualFileSize(ACTUALHANDLE handle);
extern int ActualFileSeek(ACTUALHANDLE handle, off64_t position); extern int ActualFileSeek(ACTUALHANDLE handle, off64_t position);
extern int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer); extern int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer);
extern void ActualFileClose(ACTUALHANDLE handle); extern void ActualFileClose(ACTUALHANDLE handle);
extern ACTUALHANDLE ActualFileOpenForWrite(const char *filename); extern ACTUALHANDLE ActualFileOpenForWrite(const char *filename);
extern int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer); extern int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer);
#endif /* ACTUALFILE_H */ #endif /* ACTUALFILE_H */

View File

@ -1,830 +1,453 @@
/* comparisonbox.c /* comparisonbox.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <string.h> // strcpy() #include <string.h> // strcpy()
#include <gtk/gtkbutton.h> // gtk_button_new_with_label() #include <gtk/gtkbutton.h> // gtk_button_new_with_label()
#include <gtk/gtkcontainer.h> // gtk_container_add() #include <gtk/gtkcontainer.h> // gtk_container_add()
#include <gtk/gtkentry.h> // gtk_entry_new() #include <gtk/gtkentry.h> // gtk_entry_new()
#include <gtk/gtkfilesel.h> // gtk_file_selection_set_filename() #include <gtk/gtkfilesel.h> // gtk_file_selection_set_filename()
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new() #include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
#include <gtk/gtkhbox.h> // gtk_hbox_new() #include <gtk/gtkhbox.h> // gtk_hbox_new()
#include <gtk/gtkhseparator.h> // gtk_hseparator_new() #include <gtk/gtkhseparator.h> // gtk_hseparator_new()
#include <gtk/gtklabel.h> // gtk_label_new() #include <gtk/gtklabel.h> // gtk_label_new()
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit() #include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
#include <gtk/gtkvbox.h> // gtk_vbox_new() #include <gtk/gtkvbox.h> // gtk_vbox_new()
#include <gtk/gtkwidget.h> #include <gtk/gtkwidget.h>
#include <gtk/gtkwindow.h> // gtk_window_new() #include <gtk/gtkwindow.h> // gtk_window_new()
#include "logfile.h" #include "logfile.h"
#include "conf.h" #include "conf.h"
#include "isofile.h" #include "isofile.h"
#include "isocompress.h" // compressdesc[] #include "isocompress.h" // compressdesc[]
#include "multifile.h" // multinames[] #include "multifile.h" // multinames[]
#include "tablerebuild.h" // IsoTableRebuild() #include "tablerebuild.h" // IsoTableRebuild()
#include "progressbox.h" #include "progressbox.h"
#include "messagebox.h" #include "messagebox.h"
struct MainBoxData
{
struct MainBoxData {
GtkWidget *window; // GtkWindow GtkWidget *window; // GtkWindow
GtkWidget *file1; // GtkEntry GtkWidget *file1; // GtkEntry
GtkWidget *desc1; // GtkLabel GtkWidget *desc1; // GtkLabel
GtkWidget *file2; // GtkEntry GtkWidget *file2; // GtkEntry
GtkWidget *desc2; // GtkLabel GtkWidget *desc2; // GtkLabel
GtkWidget *okbutton; // GtkButton GtkWidget *okbutton; // GtkButton
// Leaving the Cancel button unblocked... for emergency shutdown // Leaving the Cancel button unblocked... for emergency shutdown
int stop; // Variable signal to stop long processes int stop; // Variable signal to stop long processes
}; };
struct MainBoxData mainbox; struct MainBoxData mainbox;
void MainBoxDestroy()
{
if (mainbox.window != NULL)
void MainBoxDestroy() { {
if(mainbox.window != NULL) {
gtk_widget_destroy(mainbox.window); gtk_widget_destroy(mainbox.window);
mainbox.window = NULL; mainbox.window = NULL;
mainbox.file1 = NULL; mainbox.file1 = NULL;
mainbox.desc1 = NULL; mainbox.desc1 = NULL;
mainbox.file2 = NULL; mainbox.file2 = NULL;
mainbox.desc2 = NULL; mainbox.desc2 = NULL;
mainbox.okbutton = NULL; mainbox.okbutton = NULL;
} // ENDIF- Do we have a Main Window still? } // ENDIF- Do we have a Main Window still?
} // END MainBoxDestroy() } // END MainBoxDestroy()
void MainBoxUnfocus()
{
void MainBoxUnfocus() {
gtk_widget_set_sensitive(mainbox.file1, FALSE); gtk_widget_set_sensitive(mainbox.file1, FALSE);
gtk_widget_set_sensitive(mainbox.file2, FALSE); gtk_widget_set_sensitive(mainbox.file2, FALSE);
gtk_widget_set_sensitive(mainbox.okbutton, FALSE); gtk_widget_set_sensitive(mainbox.okbutton, FALSE);
gtk_window_iconify(GTK_WINDOW(mainbox.window)); gtk_window_iconify(GTK_WINDOW(mainbox.window));
} // END MainBoxUnfocus() } // END MainBoxUnfocus()
gint MainBoxFile1Event(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint MainBoxFile1Event(GtkWidget *widget, GdkEvent event, gpointer data) {
int returnval; int returnval;
char templine[256]; char templine[256];
struct IsoFile *tempfile; struct IsoFile *tempfile;
returnval = IsIsoFile(gtk_entry_get_text(GTK_ENTRY(mainbox.file1))); returnval = IsIsoFile(gtk_entry_get_text(GTK_ENTRY(mainbox.file1)));
if (returnval == -1)
if(returnval == -1) { {
gtk_label_set_text(GTK_LABEL(mainbox.desc1), "File Type: ---"); gtk_label_set_text(GTK_LABEL(mainbox.desc1), "File Type: ---");
return(TRUE); return(TRUE);
} // ENDIF- Not a name of any sort? } // ENDIF- Not a name of any sort?
if (returnval == -2)
{
if(returnval == -2) {
gtk_label_set_text(GTK_LABEL(mainbox.desc1), "File Type: Not a file"); gtk_label_set_text(GTK_LABEL(mainbox.desc1), "File Type: Not a file");
return(TRUE); return(TRUE);
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
if (returnval == -3)
{
if(returnval == -3) {
gtk_label_set_text(GTK_LABEL(mainbox.desc1), "File Type: Not a valid image file"); gtk_label_set_text(GTK_LABEL(mainbox.desc1), "File Type: Not a valid image file");
return(TRUE); return(TRUE);
} // ENDIF- Not an Image file? } // ENDIF- Not an Image file?
if (returnval == -4)
{
if(returnval == -4) {
gtk_label_set_text(GTK_LABEL(mainbox.desc1), "File Type: Missing Table File (will rebuild)"); gtk_label_set_text(GTK_LABEL(mainbox.desc1), "File Type: Missing Table File (will rebuild)");
return(TRUE); return(TRUE);
} // ENDIF- Missing Compression seek table? } // ENDIF- Missing Compression seek table?
tempfile = IsoFileOpenForRead(gtk_entry_get_text(GTK_ENTRY(mainbox.file1))); tempfile = IsoFileOpenForRead(gtk_entry_get_text(GTK_ENTRY(mainbox.file1)));
sprintf(templine, "File Type: %s%s%s", sprintf(templine, "File Type: %s%s%s",
multinames[tempfile->multi], multinames[tempfile->multi],
tempfile->imagename, tempfile->imagename,
compressdesc[tempfile->compress]); compressdesc[tempfile->compress]);
gtk_label_set_text(GTK_LABEL(mainbox.desc1), templine); gtk_label_set_text(GTK_LABEL(mainbox.desc1), templine);
tempfile = IsoFileClose(tempfile); tempfile = IsoFileClose(tempfile);
return(TRUE); return(TRUE);
} // END MainBoxFileEvent() } // END MainBoxFileEvent()
gint MainBoxFile2Event(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint MainBoxFile2Event(GtkWidget *widget, GdkEvent event, gpointer data) {
int returnval; int returnval;
char templine[256]; char templine[256];
struct IsoFile *tempfile; struct IsoFile *tempfile;
returnval = IsIsoFile(gtk_entry_get_text(GTK_ENTRY(mainbox.file2))); returnval = IsIsoFile(gtk_entry_get_text(GTK_ENTRY(mainbox.file2)));
if (returnval == -1)
if(returnval == -1) { {
gtk_label_set_text(GTK_LABEL(mainbox.desc2), "File Type: ---"); gtk_label_set_text(GTK_LABEL(mainbox.desc2), "File Type: ---");
return(TRUE); return(TRUE);
} // ENDIF- Not a name of any sort? } // ENDIF- Not a name of any sort?
if (returnval == -2)
{
if(returnval == -2) {
gtk_label_set_text(GTK_LABEL(mainbox.desc2), "File Type: Not a file"); gtk_label_set_text(GTK_LABEL(mainbox.desc2), "File Type: Not a file");
return(TRUE); return(TRUE);
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
if (returnval == -3)
{
if(returnval == -3) {
gtk_label_set_text(GTK_LABEL(mainbox.desc2), "File Type: Not a valid image file"); gtk_label_set_text(GTK_LABEL(mainbox.desc2), "File Type: Not a valid image file");
return(TRUE); return(TRUE);
} // ENDIF- Not an Image file? } // ENDIF- Not an Image file?
if (returnval == -4)
{
if(returnval == -4) {
gtk_label_set_text(GTK_LABEL(mainbox.desc2), "File Type: Missing Table File (will rebuild)"); gtk_label_set_text(GTK_LABEL(mainbox.desc2), "File Type: Missing Table File (will rebuild)");
return(TRUE); return(TRUE);
} // ENDIF- Missing Compression seek table? } // ENDIF- Missing Compression seek table?
tempfile = IsoFileOpenForRead(gtk_entry_get_text(GTK_ENTRY(mainbox.file2))); tempfile = IsoFileOpenForRead(gtk_entry_get_text(GTK_ENTRY(mainbox.file2)));
sprintf(templine, "File Type: %s%s%s", sprintf(templine, "File Type: %s%s%s",
multinames[tempfile->multi], multinames[tempfile->multi],
tempfile->imagename, tempfile->imagename,
compressdesc[tempfile->compress]); compressdesc[tempfile->compress]);
gtk_label_set_text(GTK_LABEL(mainbox.desc2), templine); gtk_label_set_text(GTK_LABEL(mainbox.desc2), templine);
tempfile = IsoFileClose(tempfile); tempfile = IsoFileClose(tempfile);
return(TRUE); return(TRUE);
} // END MainBoxFileEvent() } // END MainBoxFileEvent()
void MainBoxRefocus()
{
void MainBoxRefocus() {
GdkEvent event; GdkEvent event;
MainBoxFile1Event(NULL, event, NULL); MainBoxFile1Event(NULL, event, NULL);
MainBoxFile2Event(NULL, event, NULL); MainBoxFile2Event(NULL, event, NULL);
gtk_widget_set_sensitive(mainbox.file1, TRUE); gtk_widget_set_sensitive(mainbox.file1, TRUE);
gtk_widget_set_sensitive(mainbox.file2, TRUE); gtk_widget_set_sensitive(mainbox.file2, TRUE);
gtk_widget_set_sensitive(mainbox.okbutton, TRUE); gtk_widget_set_sensitive(mainbox.okbutton, TRUE);
gtk_window_set_focus(GTK_WINDOW(mainbox.window), mainbox.file1); gtk_window_set_focus(GTK_WINDOW(mainbox.window), mainbox.file1);
gtk_window_deiconify(GTK_WINDOW(mainbox.window)); gtk_window_deiconify(GTK_WINDOW(mainbox.window));
} // END MainBoxRefocus() } // END MainBoxRefocus()
gint MainBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint MainBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
mainbox.stop = 1; // Halt all long processess... mainbox.stop = 1; // Halt all long processess...
MessageBoxDestroy(); MessageBoxDestroy();
ProgressBoxDestroy(); ProgressBoxDestroy();
MainBoxDestroy(); MainBoxDestroy();
gtk_main_quit(); gtk_main_quit();
return(TRUE); return(TRUE);
} // END MainBoxCancelEvent() } // END MainBoxCancelEvent()
gint MainBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint MainBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
const char *tempisoname1; const char *tempisoname1;
const char *tempisoname2; const char *tempisoname2;
struct IsoFile *tempiso1; struct IsoFile *tempiso1;
struct IsoFile *tempiso2; struct IsoFile *tempiso2;
int stop; int stop;
off64_t endsector; off64_t endsector;
off64_t sector; off64_t sector;
int retval; int retval;
char tempblock1[2448]; char tempblock1[2448];
char tempblock2[2448]; char tempblock2[2448];
int i; int i;
MainBoxUnfocus(); MainBoxUnfocus();
tempisoname1 = gtk_entry_get_text(GTK_ENTRY(mainbox.file1)); tempisoname1 = gtk_entry_get_text(GTK_ENTRY(mainbox.file1));
tempisoname2 = gtk_entry_get_text(GTK_ENTRY(mainbox.file2)); tempisoname2 = gtk_entry_get_text(GTK_ENTRY(mainbox.file2));
tempiso1 = NULL; tempiso1 = NULL;
tempiso2 = NULL; tempiso2 = NULL;
tempiso1 = IsoFileOpenForRead(tempisoname1); tempiso1 = IsoFileOpenForRead(tempisoname1);
if (tempiso1 == NULL)
if(tempiso1 == NULL) { {
MainBoxRefocus(); MainBoxRefocus();
MessageBoxShow("First file is not a Valid Image File.", 0); MessageBoxShow("First file is not a Valid Image File.", 0);
tempisoname1 = NULL; tempisoname1 = NULL;
tempisoname2 = NULL; tempisoname2 = NULL;
return(TRUE); return(TRUE);
} // ENDIF- Not an ISO file? Message and Stop here. } // ENDIF- Not an ISO file? Message and Stop here.
tempiso2 = IsoFileOpenForRead(tempisoname2); tempiso2 = IsoFileOpenForRead(tempisoname2);
if (tempiso2 == NULL)
if(tempiso2 == NULL) { {
MainBoxRefocus(); MainBoxRefocus();
MessageBoxShow("Second file is not a Valid Image File.", 0); MessageBoxShow("Second file is not a Valid Image File.", 0);
tempiso1 = IsoFileClose(tempiso1); tempiso1 = IsoFileClose(tempiso1);
tempisoname1 = NULL; tempisoname1 = NULL;
tempisoname2 = NULL; tempisoname2 = NULL;
return(TRUE); return(TRUE);
} // ENDIF- Not an ISO file? Message and Stop here. } // ENDIF- Not an ISO file? Message and Stop here.
if (tempiso1->blocksize != tempiso2->blocksize)
{
if(tempiso1->blocksize != tempiso2->blocksize) {
MainBoxRefocus(); MainBoxRefocus();
MessageBoxShow("Block sizes in Image files do not match.", 0); MessageBoxShow("Block sizes in Image files do not match.", 0);
tempiso1 = IsoFileClose(tempiso1); tempiso1 = IsoFileClose(tempiso1);
tempiso2 = IsoFileClose(tempiso2); tempiso2 = IsoFileClose(tempiso2);
tempisoname1 = NULL; tempisoname1 = NULL;
tempisoname2 = NULL; tempisoname2 = NULL;
return(TRUE); return(TRUE);
} // ENDIF- Not an ISO file? Message and Stop here. } // ENDIF- Not an ISO file? Message and Stop here.
if (tempiso1->multi == 1)
{
if(tempiso1->multi == 1) {
i = 0; i = 0;
while ((i < 10) && while ((i < 10) &&
(IsoFileSeek(tempiso1, tempiso1->multisectorend[i] + 1) == 0)) i++; (IsoFileSeek(tempiso1, tempiso1->multisectorend[i] + 1) == 0)) i++;
endsector = tempiso1->multisectorend[tempiso1->multiend]; endsector = tempiso1->multisectorend[tempiso1->multiend];
}
} else { else
{
endsector = tempiso1->filesectorsize; endsector = tempiso1->filesectorsize;
} // ENDIF- Get ending sector from multifile? (Or single file?) } // ENDIF- Get ending sector from multifile? (Or single file?)
IsoFileSeek(tempiso1, 0); IsoFileSeek(tempiso1, 0);
if (tempiso2->multi == 1)
{
if(tempiso2->multi == 1) {
i = 0; i = 0;
while ((i < 10) && while ((i < 10) &&
(IsoFileSeek(tempiso2, tempiso2->multisectorend[i] + 1) == 0)) i++; (IsoFileSeek(tempiso2, tempiso2->multisectorend[i] + 1) == 0)) i++;
sector = tempiso2->multisectorend[tempiso2->multiend]; sector = tempiso2->multisectorend[tempiso2->multiend];
}
} else { else
{
sector = tempiso2->filesectorsize; sector = tempiso2->filesectorsize;
} // ENDIF- Get ending sector from multifile? (Or single file?) } // ENDIF- Get ending sector from multifile? (Or single file?)
IsoFileSeek(tempiso2, 0); IsoFileSeek(tempiso2, 0);
if (sector != endsector)
if(sector != endsector) { {
MainBoxRefocus(); MainBoxRefocus();
MessageBoxShow("Number of blocks in Image files do not match.", 0); MessageBoxShow("Number of blocks in Image files do not match.", 0);
tempiso1 = IsoFileClose(tempiso1); tempiso1 = IsoFileClose(tempiso1);
tempiso2 = IsoFileClose(tempiso2); tempiso2 = IsoFileClose(tempiso2);
tempisoname1 = NULL; tempisoname1 = NULL;
tempisoname2 = NULL; tempisoname2 = NULL;
return(TRUE); return(TRUE);
} // ENDIF- Number of blocks don't match? Say so. } // ENDIF- Number of blocks don't match? Say so.
sprintf(tempblock1, "%s == %s ?", tempisoname1, tempisoname2); sprintf(tempblock1, "%s == %s ?", tempisoname1, tempisoname2);
ProgressBoxStart(tempblock1, endsector); ProgressBoxStart(tempblock1, endsector);
stop = 0; stop = 0;
mainbox.stop = 0; mainbox.stop = 0;
progressbox.stop = 0; progressbox.stop = 0;
while ((stop == 0) && (tempiso1->sectorpos < endsector))
while((stop == 0) && (tempiso1->sectorpos < endsector)) { {
retval = IsoFileRead(tempiso1, tempblock1); retval = IsoFileRead(tempiso1, tempblock1);
if (retval < 0)
if(retval < 0) { {
MainBoxRefocus(); MainBoxRefocus();
MessageBoxShow("Trouble reading first file.", 0); MessageBoxShow("Trouble reading first file.", 0);
stop = 1; stop = 1;
}
} else { else
{
retval = IsoFileRead(tempiso2, tempblock2); retval = IsoFileRead(tempiso2, tempblock2);
if (retval < 0)
if(retval < 0) { {
MainBoxRefocus(); MainBoxRefocus();
MessageBoxShow("Trouble reading second file.", 0); MessageBoxShow("Trouble reading second file.", 0);
stop = 1; stop = 1;
}
} else { else
{
i = 0; i = 0;
while ((i < tempiso1->blocksize) && (tempblock1[i] == tempblock2[i])) i++; while ((i < tempiso1->blocksize) && (tempblock1[i] == tempblock2[i])) i++;
if (i < tempiso1->blocksize)
if(i < tempiso1->blocksize) { {
MainBoxRefocus(); MainBoxRefocus();
MessageBoxShow("Trouble reading second file.", 0); MessageBoxShow("Trouble reading second file.", 0);
stop = 1; stop = 1;
} // ENDIF- Sectors don't match? Say so. } // ENDIF- Sectors don't match? Say so.
} // ENDIF- Trouble reading second file? } // ENDIF- Trouble reading second file?
} // ENDIF- Trouble reading first file? } // ENDIF- Trouble reading first file?
ProgressBoxTick(tempiso1->sectorpos); ProgressBoxTick(tempiso1->sectorpos);
while (gtk_events_pending()) gtk_main_iteration(); while (gtk_events_pending()) gtk_main_iteration();
if (mainbox.stop != 0) stop = 2; if (mainbox.stop != 0) stop = 2;
if (progressbox.stop != 0) stop = 2; if (progressbox.stop != 0) stop = 2;
} // ENDWHILE- Comparing two files... sector by sector } // ENDWHILE- Comparing two files... sector by sector
if (stop == 0)
{
if(stop == 0) {
MainBoxRefocus(); MainBoxRefocus();
MessageBoxShow("Images Match.", 0); MessageBoxShow("Images Match.", 0);
} // ENDIF- Everything checked out? Say so. } // ENDIF- Everything checked out? Say so.
tempiso1 = IsoFileClose(tempiso1); tempiso1 = IsoFileClose(tempiso1);
tempiso2 = IsoFileClose(tempiso2); tempiso2 = IsoFileClose(tempiso2);
tempisoname1 = NULL; tempisoname1 = NULL;
tempisoname2 = NULL; tempisoname2 = NULL;
return(TRUE); return(TRUE);
} // END MainBoxOKEvent() } // END MainBoxOKEvent()
void MainBoxDisplay()
{
void MainBoxDisplay() {
GtkWidget *item; GtkWidget *item;
GtkWidget *hbox1; GtkWidget *hbox1;
GtkWidget *vbox1; GtkWidget *vbox1;
mainbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); mainbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(mainbox.window), 5); gtk_container_set_border_width(GTK_CONTAINER(mainbox.window), 5);
gtk_window_set_title(GTK_WINDOW(mainbox.window), "CDVDisoEFP Comparsion"); gtk_window_set_title(GTK_WINDOW(mainbox.window), "CDVDisoEFP Comparsion");
gtk_window_set_position(GTK_WINDOW(mainbox.window), GTK_WIN_POS_CENTER); gtk_window_set_position(GTK_WINDOW(mainbox.window), GTK_WIN_POS_CENTER);
// gtk_window_set_resizable(GTK_WINDOW(mainbox.window), FALSE); // gtk_window_set_resizable(GTK_WINDOW(mainbox.window), FALSE);
g_signal_connect(G_OBJECT(mainbox.window), "delete_event", g_signal_connect(G_OBJECT(mainbox.window), "delete_event",
G_CALLBACK(MainBoxCancelEvent), NULL); G_CALLBACK(MainBoxCancelEvent), NULL);
vbox1 = gtk_vbox_new(FALSE, 5); vbox1 = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(mainbox.window), vbox1); gtk_container_add(GTK_CONTAINER(mainbox.window), vbox1);
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5); gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
gtk_widget_show(vbox1); gtk_widget_show(vbox1);
hbox1 = gtk_hbox_new(FALSE, 10); hbox1 = gtk_hbox_new(FALSE, 10);
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
item = gtk_label_new("First Iso File:"); item = gtk_label_new("First Iso File:");
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
mainbox.file1 = gtk_entry_new(); mainbox.file1 = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.file1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), mainbox.file1, TRUE, TRUE, 0);
gtk_widget_show(mainbox.file1); gtk_widget_show(mainbox.file1);
g_signal_connect(G_OBJECT(mainbox.file1), "changed", g_signal_connect(G_OBJECT(mainbox.file1), "changed",
G_CALLBACK(MainBoxFile1Event), NULL); G_CALLBACK(MainBoxFile1Event), NULL);
hbox1 = NULL; hbox1 = NULL;
mainbox.desc1 = gtk_label_new("File Type: ---"); mainbox.desc1 = gtk_label_new("File Type: ---");
gtk_box_pack_start(GTK_BOX(vbox1), mainbox.desc1, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), mainbox.desc1, FALSE, FALSE, 0);
gtk_widget_show(mainbox.desc1); gtk_widget_show(mainbox.desc1);
item = gtk_hseparator_new(); item = gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(vbox1), item, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), item, TRUE, TRUE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
hbox1 = gtk_hbox_new(FALSE, 10); hbox1 = gtk_hbox_new(FALSE, 10);
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
item = gtk_label_new("Second Iso File:"); item = gtk_label_new("Second Iso File:");
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
mainbox.file2 = gtk_entry_new(); mainbox.file2 = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.file2, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), mainbox.file2, TRUE, TRUE, 0);
gtk_widget_show(mainbox.file2); gtk_widget_show(mainbox.file2);
g_signal_connect(G_OBJECT(mainbox.file2), "changed", g_signal_connect(G_OBJECT(mainbox.file2), "changed",
G_CALLBACK(MainBoxFile2Event), NULL); G_CALLBACK(MainBoxFile2Event), NULL);
hbox1 = NULL; hbox1 = NULL;
mainbox.desc2 = gtk_label_new("File Type: ---"); mainbox.desc2 = gtk_label_new("File Type: ---");
gtk_box_pack_start(GTK_BOX(vbox1), mainbox.desc2, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), mainbox.desc2, FALSE, FALSE, 0);
gtk_widget_show(mainbox.desc2); gtk_widget_show(mainbox.desc2);
hbox1 = gtk_hbutton_box_new(); hbox1 = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
mainbox.okbutton = gtk_button_new_with_label("Compare"); mainbox.okbutton = gtk_button_new_with_label("Compare");
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.okbutton, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), mainbox.okbutton, TRUE, TRUE, 0);
gtk_widget_show(mainbox.okbutton); gtk_widget_show(mainbox.okbutton);
g_signal_connect(G_OBJECT(mainbox.okbutton), "clicked", g_signal_connect(G_OBJECT(mainbox.okbutton), "clicked",
G_CALLBACK(MainBoxOKEvent), NULL); G_CALLBACK(MainBoxOKEvent), NULL);
item = gtk_button_new_with_label("Exit"); item = gtk_button_new_with_label("Exit");
gtk_box_pack_start(GTK_BOX(hbox1), item, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), item, TRUE, TRUE, 0);
gtk_widget_show(item); gtk_widget_show(item);
g_signal_connect(G_OBJECT(item), "clicked", g_signal_connect(G_OBJECT(item), "clicked",
G_CALLBACK(MainBoxCancelEvent), NULL); G_CALLBACK(MainBoxCancelEvent), NULL);
item = NULL; item = NULL;
hbox1 = NULL; hbox1 = NULL;
vbox1 = NULL; vbox1 = NULL;
// We held off setting the name until now... so description would show. // We held off setting the name until now... so description would show.
gtk_entry_set_text(GTK_ENTRY(mainbox.file1), conf.isoname); gtk_entry_set_text(GTK_ENTRY(mainbox.file1), conf.isoname);
gtk_entry_set_text(GTK_ENTRY(mainbox.file2), conf.isoname); gtk_entry_set_text(GTK_ENTRY(mainbox.file2), conf.isoname);
} // END MainBoxDisplay() } // END MainBoxDisplay()
int main(int argc, char *argv[])
{
int main(int argc, char *argv[]) {
gtk_init(NULL, NULL); gtk_init(NULL, NULL);
OpenLog(); OpenLog();
InitConf(); InitConf();
LoadConf(); LoadConf();
MainBoxDisplay(); MainBoxDisplay();
ProgressBoxDisplay(); ProgressBoxDisplay();
MessageBoxDisplay(); MessageBoxDisplay();
gtk_widget_show_all(mainbox.window); gtk_widget_show_all(mainbox.window);
gtk_main(); gtk_main();
CloseLog(); CloseLog();
return(0); return(0);
} // END main() } // END main()

View File

@ -1,48 +1,30 @@
/* comparisondummy.c /* comparisondummy.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
void ConversionBoxRefocus()
{
return;
}
void DeviceBoxRefocus()
{
void ConversionBoxRefocus() { return; } return;
}
void DeviceBoxRefocus() { return; }

View File

@ -1,408 +1,204 @@
/* conf.c /* conf.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <errno.h> // errno #include <errno.h> // errno
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <stdlib.h> // getenv() #include <stdlib.h> // getenv()
#include <string.h> // strerror() #include <string.h> // strerror()
#include <sys/stat.h> // mkdir(), stat() #include <sys/stat.h> // mkdir(), stat()
#include <sys/types.h> // mkdir(), stat() #include <sys/types.h> // mkdir(), stat()
#include <unistd.h> // stat() #include <unistd.h> // stat()
// #define CDVDdefs // #define CDVDdefs
// #include "../PS2Edefs.h" // #include "../PS2Edefs.h"
#include "logfile.h" #include "logfile.h"
#include "../ini.h" #include "../ini.h"
#include "conf.h" #include "conf.h"
const char *cfgname[] = { \ const char *cfgname[] = { \
"./cfg/cfgCDVDisoEFP", \ "./cfg/cfgCDVDisoEFP", \
"../cfg/cfgCDVDisoEFP", \ "../cfg/cfgCDVDisoEFP", \
"./cfgCDVDisoEFP", \ "./cfgCDVDisoEFP", \
"../cfgCDVDisoEFP", \ "../cfgCDVDisoEFP", \
"./plugins/cfgCDVDisoEFP", \ "./plugins/cfgCDVDisoEFP", \
"../plugins/cfgCDVDisoEFP", \ "../plugins/cfgCDVDisoEFP", \
NULL
NULL }; };
const char *confnames[] = { "IsoFile", "CdDev", NULL }; const char *confnames[] = { "IsoFile", "CdDev", NULL };
const u8 defaultdevice[] = DEFAULT_DEVICE; const u8 defaultdevice[] = DEFAULT_DEVICE;
const char defaulthome[] = "../inis"; const char defaulthome[] = "../inis";
const char defaultdirectory[] = ".PS2E"; const char defaultdirectory[] = ".PS2E";
const char defaultfile[] = "CDVDisoEFP.ini"; const char defaultfile[] = "CDVDisoEFP.ini";
char confdirname[256]; char confdirname[256];
char conffilename[256]; char conffilename[256];
CDVDconf conf; CDVDconf conf;
void ExecCfg(char *arg)
{
void ExecCfg(char *arg) {
int nameptr; int nameptr;
struct stat filestat; struct stat filestat;
char templine[256]; char templine[256];
#ifdef VERBOSE_FUNCTION_CONF #ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVDiso interface: ExecCfg(%s)", arg); PrintLog("CDVDiso interface: ExecCfg(%s)", arg);
#endif /* VERBOSE FUNCTION_CONF */ #endif /* VERBOSE FUNCTION_CONF */
errno = 0; errno = 0;
nameptr = 0; nameptr = 0;
while ((cfgname[nameptr] != NULL) && while ((cfgname[nameptr] != NULL) &&
(stat(cfgname[nameptr], &filestat) == -1)) nameptr++; (stat(cfgname[nameptr], &filestat) == -1)) nameptr++;
errno = 0; errno = 0;
if (cfgname[nameptr] == NULL)
{
if(cfgname[nameptr] == NULL) {
#ifdef VERBOSE_FUNCTION_CONF #ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVDiso interface: Couldn't find configuration program!"); PrintLog("CDVDiso interface: Couldn't find configuration program!");
#endif /* VERBOSE_FUNCTION_CONF */ #endif /* VERBOSE_FUNCTION_CONF */
return; return;
} // ENDIF- Did not find the executable? } // ENDIF- Did not find the executable?
sprintf(templine, "%s %s", cfgname[nameptr], arg); sprintf(templine, "%s %s", cfgname[nameptr], arg);
system(templine); system(templine);
} // END ExecCfg() } // END ExecCfg()
void InitConf()
{
void InitConf() {
int i; int i;
int pos; int pos;
char *envptr; char *envptr;
#ifdef VERBOSE_FUNCTION_CONF #ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: InitConf()"); PrintLog("CDVD config: InitConf()");
#endif /* VERBOSE_FUNCTION_CONF */ #endif /* VERBOSE_FUNCTION_CONF */
conf.isoname[0] = 0; // Empty the iso name conf.isoname[0] = 0; // Empty the iso name
i = 0; i = 0;
while ((i < 255) && defaultdevice[i] != 0)
while((i < 255) && defaultdevice[i] != 0) { {
conf.devicename[i] = defaultdevice[i]; conf.devicename[i] = defaultdevice[i];
i++; i++;
} // ENDWHILE- copying the default CD/DVD name in } // ENDWHILE- copying the default CD/DVD name in
conf.devicename[i] = 0; // 0-terminate the device name conf.devicename[i] = 0; // 0-terminate the device name
// Locating directory and file positions // Locating directory and file positions
pos = 0; pos = 0;
envptr = getenv("HOME"); envptr = getenv("HOME");
if (envptr == NULL)
if(envptr == NULL) { {
// = <Default Home> // = <Default Home>
i = 0; i = 0;
while ((pos < 253) && (defaulthome[i] != 0))
while((pos < 253) && (defaulthome[i] != 0)) { {
confdirname[pos] = defaulthome[i]; confdirname[pos] = defaulthome[i];
conffilename[pos] = defaulthome[i]; conffilename[pos] = defaulthome[i];
pos++; pos++;
i++; i++;
} // NEXT- putting a default place to store configuration data } // NEXT- putting a default place to store configuration data
}
else
{
} else {
// = <Env Home>/<Default Directory> // = <Env Home>/<Default Directory>
i = 0; i = 0;
while ((pos < 253) && (*(envptr + i) != 0))
while((pos < 253) && (*(envptr + i) != 0)) { {
confdirname[pos] = *(envptr + i); confdirname[pos] = *(envptr + i);
conffilename[pos] = *(envptr + i); conffilename[pos] = *(envptr + i);
pos++; pos++;
i++; i++;
} // ENDWHILE- copying home directory info in } // ENDWHILE- copying home directory info in
if (confdirname[pos-1] != '/')
{
if(confdirname[pos-1] != '/') {
confdirname[pos] = '/'; confdirname[pos] = '/';
conffilename[pos] = '/'; conffilename[pos] = '/';
pos++; pos++;
} // ENDIF- No directory separator here? Add one. } // ENDIF- No directory separator here? Add one.
i = 0; i = 0;
while ((pos < 253) && (defaultdirectory[i] != 0))
while((pos < 253) && (defaultdirectory[i] != 0)) { {
confdirname[pos] = defaultdirectory[i]; confdirname[pos] = defaultdirectory[i];
conffilename[pos] = defaultdirectory[i]; conffilename[pos] = defaultdirectory[i];
pos++; pos++;
i++; i++;
} // NEXT- putting a default place to store configuration data } // NEXT- putting a default place to store configuration data
} // ENDIF- No Home directory? } // ENDIF- No Home directory?
confdirname[pos] = 0; // Directory reference finished confdirname[pos] = 0; // Directory reference finished
// += /<Config File Name> // += /<Config File Name>
if (conffilename[pos-1] != '/')
if(conffilename[pos-1] != '/') { {
conffilename[pos] = '/'; conffilename[pos] = '/';
pos++; pos++;
} // ENDIF- No directory separator here? Add one. } // ENDIF- No directory separator here? Add one.
i = 0; i = 0;
while ((pos < 253) && (defaultfile[i] != 0))
while((pos < 253) && (defaultfile[i] != 0)) { {
conffilename[pos] = defaultfile[i]; conffilename[pos] = defaultfile[i];
pos++; pos++;
i++; i++;
} // NEXT- putting a default place to store configuration data } // NEXT- putting a default place to store configuration data
conffilename[pos] = 0; // File reference finished conffilename[pos] = 0; // File reference finished
#ifdef VERBOSE_FUNCTION_CONF #ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: Directory: %s\n", confdirname); PrintLog("CDVD config: Directory: %s\n", confdirname);
PrintLog("CDVD config: File: %s\n", conffilename); PrintLog("CDVD config: File: %s\n", conffilename);
#endif /* VERBOSE_FUNCTION_CONF */ #endif /* VERBOSE_FUNCTION_CONF */
} // END InitConf() } // END InitConf()
void LoadConf()
{
void LoadConf() {
int retval; int retval;
#ifdef VERBOSE_FUNCTION_CONF #ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: LoadConf()\n"); PrintLog("CDVD config: LoadConf()\n");
#endif /* VERBOSE_FUNCTION_CONF */ #endif /* VERBOSE_FUNCTION_CONF */
retval = INILoadString(conffilename, "Settings", "IsoFile", conf.isoname); retval = INILoadString(conffilename, "Settings", "IsoFile", conf.isoname);
if (retval < 0)
if(retval < 0) { {
sprintf(conf.isoname, "[Put an Image Name here]"); sprintf(conf.isoname, "[Put an Image Name here]");
} // ENDIF- Couldn't find keyword? Fill in a default } // ENDIF- Couldn't find keyword? Fill in a default
retval = INILoadString(conffilename, "Settings", "Device", conf.devicename); retval = INILoadString(conffilename, "Settings", "Device", conf.devicename);
if (retval < 0)
if(retval < 0) { {
sprintf(conf.devicename, "/dev/dvd"); sprintf(conf.devicename, "/dev/dvd");
} // ENDIF- Couldn't find keyword? Fill in a default } // ENDIF- Couldn't find keyword? Fill in a default
retval = INILoadUInt(conffilename, "Settings", "OpenOnStart", &conf.startconfigure); retval = INILoadUInt(conffilename, "Settings", "OpenOnStart", &conf.startconfigure);
if (retval < 0)
if(retval < 0) { {
conf.startconfigure = 0; // False conf.startconfigure = 0; // False
} // ENDIF- Couldn't find keyword? Fill in a default } // ENDIF- Couldn't find keyword? Fill in a default
retval = INILoadUInt(conffilename, "Settings", "OpenOnRestart", &conf.restartconfigure); retval = INILoadUInt(conffilename, "Settings", "OpenOnRestart", &conf.restartconfigure);
if (retval < 0)
if(retval < 0) { {
conf.restartconfigure = 1; // True conf.restartconfigure = 1; // True
} // ENDIF- Couldn't find keyword? Fill in a default } // ENDIF- Couldn't find keyword? Fill in a default
} // END LoadConf() } // END LoadConf()
void SaveConf()
{
void SaveConf() {
#ifdef VERBOSE_FUNCTION_CONF #ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: SaveConf()\n"); PrintLog("CDVD config: SaveConf()\n");
#endif /* VERBOSE_FUNCTION_CONF */ #endif /* VERBOSE_FUNCTION_CONF */
mkdir(confdirname, 0755); mkdir(confdirname, 0755);
INISaveString(conffilename, "Settings", "IsoFile", conf.isoname); INISaveString(conffilename, "Settings", "IsoFile", conf.isoname);
INISaveString(conffilename, "Settings", "Device", conf.devicename); INISaveString(conffilename, "Settings", "Device", conf.devicename);
INISaveUInt(conffilename, "Settings", "OpenOnStart", conf.startconfigure); INISaveUInt(conffilename, "Settings", "OpenOnStart", conf.startconfigure);
INISaveUInt(conffilename, "Settings", "OpenOnRestart", conf.restartconfigure); INISaveUInt(conffilename, "Settings", "OpenOnRestart", conf.restartconfigure);
} // END SaveConf() } // END SaveConf()

View File

@ -31,7 +31,8 @@
// Configuration Data // Configuration Data
typedef struct { typedef struct
{
u8 isoname[256]; u8 isoname[256];
u8 devicename[256]; u8 devicename[256];
unsigned int startconfigure; unsigned int startconfigure;

View File

@ -1,776 +1,417 @@
/* conversionbox.c /* conversionbox.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <string.h> // strcpy() #include <string.h> // strcpy()
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
#include <gtk/gtkbutton.h> // gtk_button_new_with_label() #include <gtk/gtkbutton.h> // gtk_button_new_with_label()
#include <gtk/gtkcombobox.h> // gtk_combo_box_new() #include <gtk/gtkcombobox.h> // gtk_combo_box_new()
#include <gtk/gtkcheckbutton.h> // gtk_check_button_new() #include <gtk/gtkcheckbutton.h> // gtk_check_button_new()
#include <gtk/gtkcontainer.h> // gtk_container_add() #include <gtk/gtkcontainer.h> // gtk_container_add()
#include <gtk/gtkentry.h> // gtk_entry_new() #include <gtk/gtkentry.h> // gtk_entry_new()
#include <gtk/gtkfilesel.h> // gtk_file_selection_set_filename() #include <gtk/gtkfilesel.h> // gtk_file_selection_set_filename()
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new() #include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
#include <gtk/gtkhbox.h> // gtk_hbox_new() #include <gtk/gtkhbox.h> // gtk_hbox_new()
#include <gtk/gtkhseparator.h> // gtk_hseparator_new() #include <gtk/gtkhseparator.h> // gtk_hseparator_new()
#include <gtk/gtklabel.h> // gtk_label_new() #include <gtk/gtklabel.h> // gtk_label_new()
#include <gtk/gtkmain.h> // gtk_main_iteration() #include <gtk/gtkmain.h> // gtk_main_iteration()
#include <gtk/gtktogglebutton.h> // gtk_toggle_button_get_active() #include <gtk/gtktogglebutton.h> // gtk_toggle_button_get_active()
#include <gtk/gtkvbox.h> // gtk_vbox_new() #include <gtk/gtkvbox.h> // gtk_vbox_new()
#include <gtk/gtkwindow.h> // gtk_window_new() #include <gtk/gtkwindow.h> // gtk_window_new()
#include "isofile.h" #include "isofile.h"
#include "isocompress.h" // compressdesc[] #include "isocompress.h" // compressdesc[]
#include "imagetype.h" // imagedata[] #include "imagetype.h" // imagedata[]
#include "multifile.h" // multinames[] #include "multifile.h" // multinames[]
#include "toc.h" #include "toc.h"
#include "progressbox.h" #include "progressbox.h"
#include "messagebox.h" #include "messagebox.h"
#include "selectionbox.h" #include "selectionbox.h"
#include "mainbox.h" #include "mainbox.h"
#include "conversionbox.h" #include "conversionbox.h"
struct ConversionBoxData conversionbox; struct ConversionBoxData conversionbox;
void ConversionBoxDestroy()
{
if (conversionbox.window != NULL)
void ConversionBoxDestroy() { {
if(conversionbox.window != NULL) {
gtk_widget_destroy(conversionbox.window); gtk_widget_destroy(conversionbox.window);
conversionbox.window = NULL; conversionbox.window = NULL;
conversionbox.file = NULL; conversionbox.file = NULL;
conversionbox.selectbutton = NULL; conversionbox.selectbutton = NULL;
conversionbox.filedesc = NULL; conversionbox.filedesc = NULL;
conversionbox.compress = NULL; conversionbox.compress = NULL;
conversionbox.multi = NULL; conversionbox.multi = NULL;
conversionbox.okbutton = NULL; conversionbox.okbutton = NULL;
conversionbox.cancelbutton = NULL; conversionbox.cancelbutton = NULL;
} // ENDIF- Do we have a Main Window still? } // ENDIF- Do we have a Main Window still?
} // END ConversionBoxDestroy() } // END ConversionBoxDestroy()
void ConversionBoxUnfocus()
{
void ConversionBoxUnfocus() {
gtk_widget_set_sensitive(conversionbox.file, FALSE); gtk_widget_set_sensitive(conversionbox.file, FALSE);
gtk_widget_set_sensitive(conversionbox.selectbutton, FALSE); gtk_widget_set_sensitive(conversionbox.selectbutton, FALSE);
gtk_widget_set_sensitive(conversionbox.compress, FALSE); gtk_widget_set_sensitive(conversionbox.compress, FALSE);
gtk_widget_set_sensitive(conversionbox.multi, FALSE); gtk_widget_set_sensitive(conversionbox.multi, FALSE);
gtk_widget_set_sensitive(conversionbox.okbutton, FALSE); gtk_widget_set_sensitive(conversionbox.okbutton, FALSE);
gtk_widget_set_sensitive(conversionbox.cancelbutton, FALSE); gtk_widget_set_sensitive(conversionbox.cancelbutton, FALSE);
// gtk_window_iconify(GTK_WINDOW(conversionbox.window)); // gtk_window_iconify(GTK_WINDOW(conversionbox.window));
gtk_widget_hide(conversionbox.window); gtk_widget_hide(conversionbox.window);
} // END ConversionBoxUnfocus() } // END ConversionBoxUnfocus()
gint ConversionBoxFileEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint ConversionBoxFileEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
int returnval; int returnval;
char templine[256]; char templine[256];
struct IsoFile *tempfile; struct IsoFile *tempfile;
returnval = IsIsoFile(gtk_entry_get_text(GTK_ENTRY(conversionbox.file))); returnval = IsIsoFile(gtk_entry_get_text(GTK_ENTRY(conversionbox.file)));
if (returnval == -1)
if(returnval == -1) { {
gtk_label_set_text(GTK_LABEL(conversionbox.filedesc), "File Type: ---"); gtk_label_set_text(GTK_LABEL(conversionbox.filedesc), "File Type: ---");
return(TRUE); return(TRUE);
} // ENDIF- Not a name of any sort? } // ENDIF- Not a name of any sort?
if (returnval == -2)
{
if(returnval == -2) {
gtk_label_set_text(GTK_LABEL(conversionbox.filedesc), gtk_label_set_text(GTK_LABEL(conversionbox.filedesc),
"File Type: Not a file"); "File Type: Not a file");
return(TRUE); return(TRUE);
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
if (returnval == -3)
{
if(returnval == -3) {
gtk_label_set_text(GTK_LABEL(conversionbox.filedesc), gtk_label_set_text(GTK_LABEL(conversionbox.filedesc),
"File Type: Not a valid image file"); "File Type: Not a valid image file");
return(TRUE); return(TRUE);
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
if (returnval == -4)
{
if(returnval == -4) {
gtk_label_set_text(GTK_LABEL(conversionbox.filedesc), gtk_label_set_text(GTK_LABEL(conversionbox.filedesc),
"File Type: Missing Table File (will rebuild)"); "File Type: Missing Table File (will rebuild)");
return(TRUE); return(TRUE);
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
tempfile = IsoFileOpenForRead(gtk_entry_get_text(GTK_ENTRY(conversionbox.file))); tempfile = IsoFileOpenForRead(gtk_entry_get_text(GTK_ENTRY(conversionbox.file)));
sprintf(templine, "File Type: %s%s%s", sprintf(templine, "File Type: %s%s%s",
multinames[tempfile->multi], multinames[tempfile->multi],
tempfile->imagename, tempfile->imagename,
compressdesc[tempfile->compress]); compressdesc[tempfile->compress]);
gtk_label_set_text(GTK_LABEL(conversionbox.filedesc), templine); gtk_label_set_text(GTK_LABEL(conversionbox.filedesc), templine);
tempfile = IsoFileClose(tempfile); tempfile = IsoFileClose(tempfile);
return(TRUE); return(TRUE);
} // END ConversionBoxFileEvent() } // END ConversionBoxFileEvent()
void ConversionBoxRefocus()
{
void ConversionBoxRefocus() {
GdkEvent event; GdkEvent event;
ConversionBoxFileEvent(NULL, event, NULL); ConversionBoxFileEvent(NULL, event, NULL);
gtk_widget_set_sensitive(conversionbox.file, TRUE); gtk_widget_set_sensitive(conversionbox.file, TRUE);
gtk_widget_set_sensitive(conversionbox.selectbutton, TRUE); gtk_widget_set_sensitive(conversionbox.selectbutton, TRUE);
gtk_widget_set_sensitive(conversionbox.compress, TRUE); gtk_widget_set_sensitive(conversionbox.compress, TRUE);
gtk_widget_set_sensitive(conversionbox.multi, TRUE); gtk_widget_set_sensitive(conversionbox.multi, TRUE);
gtk_widget_set_sensitive(conversionbox.okbutton, TRUE); gtk_widget_set_sensitive(conversionbox.okbutton, TRUE);
gtk_widget_set_sensitive(conversionbox.cancelbutton, TRUE); gtk_widget_set_sensitive(conversionbox.cancelbutton, TRUE);
gtk_window_set_focus(GTK_WINDOW(conversionbox.window), conversionbox.file); gtk_window_set_focus(GTK_WINDOW(conversionbox.window), conversionbox.file);
gtk_widget_show_all(conversionbox.window); gtk_widget_show_all(conversionbox.window);
gtk_window_deiconify(GTK_WINDOW(conversionbox.window)); gtk_window_deiconify(GTK_WINDOW(conversionbox.window));
} // END ConversionBoxRefocus() } // END ConversionBoxRefocus()
gint ConversionBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint ConversionBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
gtk_widget_hide(conversionbox.window); gtk_widget_hide(conversionbox.window);
MainBoxRefocus(); MainBoxRefocus();
return(TRUE); return(TRUE);
} // END ConversionBoxCancelEvent() } // END ConversionBoxCancelEvent()
gint ConversionBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint ConversionBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
char templine[256]; char templine[256];
char tempblock[2352]; char tempblock[2352];
const char *filename; const char *filename;
int compressmethod; int compressmethod;
int multi; int multi;
struct IsoFile *fromfile; struct IsoFile *fromfile;
struct IsoFile *tofile; struct IsoFile *tofile;
int i; int i;
off64_t endsector; off64_t endsector;
int stop; int stop;
int retval; int retval;
ConversionBoxUnfocus(); ConversionBoxUnfocus();
filename = gtk_entry_get_text(GTK_ENTRY(conversionbox.file)); filename = gtk_entry_get_text(GTK_ENTRY(conversionbox.file));
if (IsIsoFile(filename) < 0)
if(IsIsoFile(filename) < 0) { {
filename = NULL; filename = NULL;
MessageBoxShow("Not a valid file", 3); MessageBoxShow("Not a valid file", 3);
return(TRUE); return(TRUE);
} // ENDIF- Not an Iso File? Stop early. } // ENDIF- Not an Iso File? Stop early.
compressmethod = gtk_combo_box_get_active(GTK_COMBO_BOX(conversionbox.compress)); compressmethod = gtk_combo_box_get_active(GTK_COMBO_BOX(conversionbox.compress));
if (compressmethod > 0) compressmethod += 2; if (compressmethod > 0) compressmethod += 2;
multi = 0; multi = 0;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(conversionbox.multi)) == TRUE) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(conversionbox.multi)) == TRUE)
multi = 1; multi = 1;
fromfile = NULL; fromfile = NULL;
fromfile = IsoFileOpenForRead(filename); fromfile = IsoFileOpenForRead(filename);
if (fromfile == NULL)
if(fromfile == NULL) { {
filename = NULL; filename = NULL;
MessageBoxShow("Cannot opening the source file", 3); MessageBoxShow("Cannot opening the source file", 3);
return(TRUE); return(TRUE);
} // ENDIF- Not an Iso File? Stop early. } // ENDIF- Not an Iso File? Stop early.
if ((compressmethod == fromfile->compress) && if ((compressmethod == fromfile->compress) &&
(multi == fromfile->multi))
(multi == fromfile->multi)) { {
fromfile = IsoFileClose(fromfile); fromfile = IsoFileClose(fromfile);
filename = NULL; filename = NULL;
MessageBoxShow("Compress/Multifile methods match - no need to convert", 3); MessageBoxShow("Compress/Multifile methods match - no need to convert", 3);
return(TRUE); return(TRUE);
} // ENDIF- Not an Iso File? Stop early. } // ENDIF- Not an Iso File? Stop early.
tofile = IsoFileOpenForWrite(filename, tofile = IsoFileOpenForWrite(filename,
GetImageTypeConvertTo(fromfile->imagetype), GetImageTypeConvertTo(fromfile->imagetype),
multi, multi,
compressmethod); compressmethod);
if (tofile == NULL)
if(tofile == NULL) { {
fromfile = IsoFileClose(fromfile); fromfile = IsoFileClose(fromfile);
filename = NULL; filename = NULL;
MessageBoxShow("Cannot create the new file", 3); MessageBoxShow("Cannot create the new file", 3);
return(TRUE); return(TRUE);
} // ENDIF- Not an Iso File? Stop early. } // ENDIF- Not an Iso File? Stop early.
if (fromfile->multi == 1)
{
if(fromfile->multi == 1) {
i = 0; i = 0;
while ((i < 10) && while ((i < 10) &&
(IsoFileSeek(fromfile, fromfile->multisectorend[i] + 1) == 0)) i++; (IsoFileSeek(fromfile, fromfile->multisectorend[i] + 1) == 0)) i++;
endsector = fromfile->multisectorend[fromfile->multiend]; endsector = fromfile->multisectorend[fromfile->multiend];
}
} else { else
{
endsector = fromfile->filesectorsize; endsector = fromfile->filesectorsize;
} // ENDIF- Get ending sector from multifile? (Or single file?) } // ENDIF- Get ending sector from multifile? (Or single file?)
IsoFileSeek(fromfile, 0); IsoFileSeek(fromfile, 0);
// Open Progress Bar // Open Progress Bar
sprintf(templine, "%s: %s%s -> %s%s", sprintf(templine, "%s: %s%s -> %s%s",
filename, filename,
multinames[fromfile->multi], multinames[fromfile->multi],
compressdesc[fromfile->compress], compressdesc[fromfile->compress],
multinames[tofile->multi], multinames[tofile->multi],
compressdesc[tofile->compress]); compressdesc[tofile->compress]);
ProgressBoxStart(templine, endsector); ProgressBoxStart(templine, endsector);
tofile->cdvdtype = fromfile->cdvdtype; tofile->cdvdtype = fromfile->cdvdtype;
for (i = 0; i < 2048; i++) tofile->toc[i] = fromfile->toc[i]; for (i = 0; i < 2048; i++) tofile->toc[i] = fromfile->toc[i];
stop = 0; stop = 0;
mainbox.stop = 0; mainbox.stop = 0;
progressbox.stop = 0; progressbox.stop = 0;
while ((stop == 0) && (tofile->sectorpos < endsector))
while((stop == 0) && (tofile->sectorpos < endsector)) { {
retval = IsoFileRead(fromfile, tempblock); retval = IsoFileRead(fromfile, tempblock);
if (retval < 0)
if(retval < 0) { {
MessageBoxShow("Trouble reading source file", 3); MessageBoxShow("Trouble reading source file", 3);
stop = 1; stop = 1;
}
} else { else
{
retval = IsoFileWrite(tofile, tempblock); retval = IsoFileWrite(tofile, tempblock);
if (retval < 0)
if(retval < 0) { {
MessageBoxShow("Trouble writing new file", 3); MessageBoxShow("Trouble writing new file", 3);
stop = 1; stop = 1;
} // ENDIF- Trouble writing out the next block? } // ENDIF- Trouble writing out the next block?
} // ENDIF- Trouble reading in the next block? } // ENDIF- Trouble reading in the next block?
ProgressBoxTick(tofile->sectorpos); ProgressBoxTick(tofile->sectorpos);
while (gtk_events_pending()) gtk_main_iteration(); while (gtk_events_pending()) gtk_main_iteration();
if (mainbox.stop != 0) stop = 2; if (mainbox.stop != 0) stop = 2;
if (progressbox.stop != 0) stop = 2; if (progressbox.stop != 0) stop = 2;
} // ENDWHILE- Not stopped for some reason... } // ENDWHILE- Not stopped for some reason...
ProgressBoxStop(); ProgressBoxStop();
if (stop == 0)
{
if(stop == 0) {
if (tofile->multi == 1) tofile->name[tofile->multipos] = '0'; // First file if (tofile->multi == 1) tofile->name[tofile->multipos] = '0'; // First file
strcpy(templine, tofile->name); strcpy(templine, tofile->name);
// fromfile = IsoFileCloseAndDelete(fromfile); // fromfile = IsoFileCloseAndDelete(fromfile);
fromfile = IsoFileClose(fromfile); fromfile = IsoFileClose(fromfile);
IsoSaveTOC(tofile); IsoSaveTOC(tofile);
tofile = IsoFileClose(tofile); tofile = IsoFileClose(tofile);
gtk_entry_set_text(GTK_ENTRY(mainbox.file), templine); gtk_entry_set_text(GTK_ENTRY(mainbox.file), templine);
}
else
} else { {
fromfile = IsoFileClose(fromfile); fromfile = IsoFileClose(fromfile);
tofile = IsoFileCloseAndDelete(tofile); tofile = IsoFileCloseAndDelete(tofile);
} // ENDIF- Did we succeed in the transfer? } // ENDIF- Did we succeed in the transfer?
if (stop != 1) ConversionBoxRefocus(); if (stop != 1) ConversionBoxRefocus();
if (stop == 0) ConversionBoxCancelEvent(widget, event, data); if (stop == 0) ConversionBoxCancelEvent(widget, event, data);
return(TRUE); return(TRUE);
} // END ConversionBoxOKEvent() } // END ConversionBoxOKEvent()
gint ConversionBoxBrowseEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint ConversionBoxBrowseEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
ConversionBoxUnfocus(); ConversionBoxUnfocus();
// Transfer file name to file selection // Transfer file name to file selection
gtk_file_selection_set_filename(GTK_FILE_SELECTION(selectionbox.window), gtk_file_selection_set_filename(GTK_FILE_SELECTION(selectionbox.window),
gtk_entry_get_text(GTK_ENTRY(conversionbox.file))); gtk_entry_get_text(GTK_ENTRY(conversionbox.file)));
selectionbox.wherefrom = 3; // From the Conversion Window selectionbox.wherefrom = 3; // From the Conversion Window
SelectionBoxRefocus(); SelectionBoxRefocus();
return(TRUE); return(TRUE);
} // END ConversionBoxBrowseEvent() } // END ConversionBoxBrowseEvent()
void ConversionBoxDisplay()
{
void ConversionBoxDisplay() {
GtkWidget *item; GtkWidget *item;
GtkWidget *hbox1; GtkWidget *hbox1;
GtkWidget *vbox1; GtkWidget *vbox1;
int nameptr; int nameptr;
conversionbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); conversionbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(conversionbox.window), 5); gtk_container_set_border_width(GTK_CONTAINER(conversionbox.window), 5);
gtk_window_set_title(GTK_WINDOW(conversionbox.window), "CDVDisoEFP File Conversion"); gtk_window_set_title(GTK_WINDOW(conversionbox.window), "CDVDisoEFP File Conversion");
gtk_window_set_position(GTK_WINDOW(conversionbox.window), GTK_WIN_POS_CENTER); gtk_window_set_position(GTK_WINDOW(conversionbox.window), GTK_WIN_POS_CENTER);
g_signal_connect(G_OBJECT(conversionbox.window), "delete_event", g_signal_connect(G_OBJECT(conversionbox.window), "delete_event",
G_CALLBACK(ConversionBoxCancelEvent), NULL); G_CALLBACK(ConversionBoxCancelEvent), NULL);
vbox1 = gtk_vbox_new(FALSE, 5); vbox1 = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(conversionbox.window), vbox1); gtk_container_add(GTK_CONTAINER(conversionbox.window), vbox1);
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5); gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
gtk_widget_show(vbox1); gtk_widget_show(vbox1);
hbox1 = gtk_hbox_new(FALSE, 10); hbox1 = gtk_hbox_new(FALSE, 10);
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
item = gtk_label_new("Iso File:"); item = gtk_label_new("Iso File:");
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
conversionbox.file = gtk_entry_new(); conversionbox.file = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.file, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.file, TRUE, TRUE, 0);
gtk_widget_show(conversionbox.file); gtk_widget_show(conversionbox.file);
g_signal_connect(G_OBJECT(conversionbox.file), "changed", g_signal_connect(G_OBJECT(conversionbox.file), "changed",
G_CALLBACK(ConversionBoxFileEvent), NULL); G_CALLBACK(ConversionBoxFileEvent), NULL);
conversionbox.selectbutton = gtk_button_new_with_label("Browse"); conversionbox.selectbutton = gtk_button_new_with_label("Browse");
gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.selectbutton, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.selectbutton, FALSE, FALSE, 0);
gtk_widget_show(conversionbox.selectbutton); gtk_widget_show(conversionbox.selectbutton);
g_signal_connect(G_OBJECT(conversionbox.selectbutton), "clicked", g_signal_connect(G_OBJECT(conversionbox.selectbutton), "clicked",
G_CALLBACK(ConversionBoxBrowseEvent), NULL); G_CALLBACK(ConversionBoxBrowseEvent), NULL);
hbox1 = NULL; hbox1 = NULL;
conversionbox.filedesc = gtk_label_new("File Type: ---"); conversionbox.filedesc = gtk_label_new("File Type: ---");
gtk_box_pack_start(GTK_BOX(vbox1), conversionbox.filedesc, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), conversionbox.filedesc, FALSE, FALSE, 0);
gtk_widget_show(conversionbox.filedesc); gtk_widget_show(conversionbox.filedesc);
// ConversionBoxFileEvent(NULL, 0, NULL); // Work out compromise later... // ConversionBoxFileEvent(NULL, 0, NULL); // Work out compromise later...
item = gtk_hseparator_new(); item = gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(vbox1), item, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), item, TRUE, TRUE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
hbox1 = gtk_hbox_new(FALSE, 10); hbox1 = gtk_hbox_new(FALSE, 10);
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
item = gtk_label_new("Change Compression To:"); item = gtk_label_new("Change Compression To:");
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
conversionbox.compress = gtk_combo_box_new_text(); conversionbox.compress = gtk_combo_box_new_text();
gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.compress, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.compress, FALSE, FALSE, 0);
nameptr = 0; nameptr = 0;
while (compressnames[nameptr] != NULL)
while(compressnames[nameptr] != NULL) { {
gtk_combo_box_append_text(GTK_COMBO_BOX(conversionbox.compress), gtk_combo_box_append_text(GTK_COMBO_BOX(conversionbox.compress),
compressnames[nameptr]); compressnames[nameptr]);
nameptr++; nameptr++;
} // ENDWHILE- loading compression types into combo box } // ENDWHILE- loading compression types into combo box
gtk_combo_box_set_active(GTK_COMBO_BOX(conversionbox.compress), 0); // Temp Line gtk_combo_box_set_active(GTK_COMBO_BOX(conversionbox.compress), 0); // Temp Line
gtk_widget_show(conversionbox.compress); gtk_widget_show(conversionbox.compress);
hbox1 = NULL; hbox1 = NULL;
hbox1 = gtk_hbox_new(FALSE, 10); hbox1 = gtk_hbox_new(FALSE, 10);
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
item = gtk_label_new("Multiple Files (all under 2 GB):"); item = gtk_label_new("Multiple Files (all under 2 GB):");
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
conversionbox.multi = gtk_check_button_new(); conversionbox.multi = gtk_check_button_new();
gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.multi, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.multi, FALSE, FALSE, 0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(conversionbox.multi), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(conversionbox.multi), FALSE);
gtk_widget_show(conversionbox.multi); gtk_widget_show(conversionbox.multi);
hbox1 = NULL; hbox1 = NULL;
hbox1 = gtk_hbutton_box_new(); hbox1 = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
conversionbox.okbutton = gtk_button_new_with_label("Change File"); conversionbox.okbutton = gtk_button_new_with_label("Change File");
gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.okbutton, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.okbutton, TRUE, TRUE, 0);
gtk_widget_show(conversionbox.okbutton); gtk_widget_show(conversionbox.okbutton);
g_signal_connect(G_OBJECT(conversionbox.okbutton), "clicked", g_signal_connect(G_OBJECT(conversionbox.okbutton), "clicked",
G_CALLBACK(ConversionBoxOKEvent), NULL); G_CALLBACK(ConversionBoxOKEvent), NULL);
conversionbox.cancelbutton = gtk_button_new_with_label("Cancel"); conversionbox.cancelbutton = gtk_button_new_with_label("Cancel");
gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.cancelbutton, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.cancelbutton, TRUE, TRUE, 0);
gtk_widget_show(conversionbox.cancelbutton); gtk_widget_show(conversionbox.cancelbutton);
g_signal_connect(G_OBJECT(conversionbox.cancelbutton), "clicked", g_signal_connect(G_OBJECT(conversionbox.cancelbutton), "clicked",
G_CALLBACK(ConversionBoxCancelEvent), NULL); G_CALLBACK(ConversionBoxCancelEvent), NULL);
hbox1 = NULL; hbox1 = NULL;
vbox1 = NULL; vbox1 = NULL;
} // END ConversionBoxDisplay() } // END ConversionBoxDisplay()

View File

@ -1,94 +1,44 @@
/* conversionbox.h /* conversionbox.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef CONVERSIONBOX_H #ifndef CONVERSIONBOX_H
#define CONVERSIONBOX_H #define CONVERSIONBOX_H
#include <gtk/gtkwidget.h> #include <gtk/gtkwidget.h>
struct ConversionBoxData
{
struct ConversionBoxData {
GtkWidget *window; // GtkWindow GtkWidget *window; // GtkWindow
GtkWidget *file; // GtkEntry GtkWidget *file; // GtkEntry
GtkWidget *selectbutton; // GtkButton GtkWidget *selectbutton; // GtkButton
GtkWidget *filedesc; // GtkLabel GtkWidget *filedesc; // GtkLabel
GtkWidget *compress; // GtkComboBox GtkWidget *compress; // GtkComboBox
GtkWidget *multi; // GtkCheckButton GtkWidget *multi; // GtkCheckButton
GtkWidget *okbutton; // GtkButton GtkWidget *okbutton; // GtkButton
GtkWidget *cancelbutton; // GtkButton GtkWidget *cancelbutton; // GtkButton
}; };
extern struct ConversionBoxData conversionbox; extern struct ConversionBoxData conversionbox;
extern void ConversionBoxDestroy(); extern void ConversionBoxDestroy();
extern void ConversionBoxRefocus(); extern void ConversionBoxRefocus();
extern void ConversionBoxDisplay(); extern void ConversionBoxDisplay();
#endif /* CONVERSIONBOX_H */ #endif /* CONVERSIONBOX_H */

View File

@ -17,7 +17,6 @@
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <errno.h> // errno #include <errno.h> // errno
#include <fcntl.h> // open() #include <fcntl.h> // open()
#include <stddef.h> // NULL #include <stddef.h> // NULL
@ -28,46 +27,37 @@
#include <sys/types.h> // open() #include <sys/types.h> // open()
#include <time.h> // time_t, time(), struct timeval #include <time.h> // time_t, time(), struct timeval
#include <unistd.h> // close(), select() #include <unistd.h> // close(), select()
#include <linux/cdrom.h> // CD/DVD based ioctl() and defines. #include <linux/cdrom.h> // CD/DVD based ioctl() and defines.
#include "logfile.h" #include "logfile.h"
#include "conf.h" #include "conf.h"
#include "CD.h" #include "CD.h"
#include "DVD.h" #include "DVD.h"
#include "device.h" #include "device.h"
// Globals // Globals
int devicehandle; // File Handle for the device/drive int devicehandle; // File Handle for the device/drive
s32 devicecapability; // Capability Flags s32 devicecapability; // Capability Flags
time_t lasttime; // Time marker (in case something gets called too often) time_t lasttime; // Time marker (in case something gets called too often)
s32 traystatus; // Is the CD/DVD tray open? s32 traystatus; // Is the CD/DVD tray open?
s32 disctype; // Type of disc in drive (Video DVD, PSX CD, etc.) s32 disctype; // Type of disc in drive (Video DVD, PSX CD, etc.)
u8 tocbuffer[2048]; u8 tocbuffer[2048];
void DeviceInit()
void DeviceInit() { {
devicehandle = -1; devicehandle = -1;
devicecapability = 0; devicecapability = 0;
lasttime = time(NULL); lasttime = time(NULL);
InitDisc(); InitDisc();
} // END DeviceInit() } // END DeviceInit()
// Called by DeviceOpen(), DeviceGetDiskType() // Called by DeviceOpen(), DeviceGetDiskType()
void InitDisc() { void InitDisc()
{
int i; int i;
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: InitDisc()"); PrintLog("CDVD device: InitDisc()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
if ((disctype == CDVD_TYPE_PS2DVD) || if ((disctype == CDVD_TYPE_PS2DVD) ||
(disctype == CDVD_TYPE_DVDV)) { (disctype == CDVD_TYPE_DVDV))
{
InitDVDInfo(); InitDVDInfo();
} // ENDIF- Clean out DVD Disc Info? } // ENDIF- Clean out DVD Disc Info?
@ -75,7 +65,8 @@ void InitDisc() {
(disctype == CDVD_TYPE_PS2CDDA) || (disctype == CDVD_TYPE_PS2CDDA) ||
(disctype == CDVD_TYPE_PSCD) || (disctype == CDVD_TYPE_PSCD) ||
(disctype == CDVD_TYPE_PSCDDA) || (disctype == CDVD_TYPE_PSCDDA) ||
(disctype == CDVD_TYPE_CDDA)) { (disctype == CDVD_TYPE_CDDA))
{
InitCDInfo(); InitCDInfo();
} // ENDIF- Clean out DVD Disc Info? } // ENDIF- Clean out DVD Disc Info?
@ -83,8 +74,8 @@ void InitDisc() {
for (i = 0; i > sizeof(tocbuffer); i++) tocbuffer[i] = 0x00; for (i = 0; i > sizeof(tocbuffer); i++) tocbuffer[i] = 0x00;
} // END InitDisc() } // END InitDisc()
s32 DiscInserted()
s32 DiscInserted() { {
if (devicehandle == -1) return(-1); if (devicehandle == -1) return(-1);
if (traystatus == CDVD_TRAY_OPEN) return(-1); if (traystatus == CDVD_TRAY_OPEN) return(-1);
if (disctype == CDVD_TYPE_ILLEGAL) return(-1); if (disctype == CDVD_TYPE_ILLEGAL) return(-1);
@ -94,37 +85,35 @@ s32 DiscInserted() {
if (disctype == CDVD_TYPE_DETCTCD) return(-1); if (disctype == CDVD_TYPE_DETCTCD) return(-1);
if (disctype == CDVD_TYPE_DETCT) return(-1); if (disctype == CDVD_TYPE_DETCT) return(-1);
if (disctype == CDVD_TYPE_NODISC) return(-1); if (disctype == CDVD_TYPE_NODISC) return(-1);
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DiscInserted()"); PrintLog("CDVD device: DiscInserted()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
return(0); return(0);
} // END DiscInserted() } // END DiscInserted()
// Called by DeviceTrayStatus() and CDVDopen() // Called by DeviceTrayStatus() and CDVDopen()
s32 DeviceOpen() { s32 DeviceOpen()
{
// s32 s32result; // s32 s32result;
errno = 0; errno = 0;
if(devicehandle != -1) { if (devicehandle != -1)
{
#ifdef VERBOSE_WARNING_DEVICE #ifdef VERBOSE_WARNING_DEVICE
PrintLog("CDVD device: Device already open!"); PrintLog("CDVD device: Device already open!");
#endif /* VERBOSE_WARNING_DEVICE */ #endif /* VERBOSE_WARNING_DEVICE */
return(0); return(0);
} // ENDIF- Is the CD/DVD already in use? That's fine. } // ENDIF- Is the CD/DVD already in use? That's fine.
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DeviceOpen()"); PrintLog("CDVD device: DeviceOpen()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
// InitConf(); // InitConf();
// LoadConf(); // Should be done once before making this call // LoadConf(); // Should be done once before making this call
devicehandle = open(conf.devicename, O_RDONLY | O_NONBLOCK); devicehandle = open(conf.devicename, O_RDONLY | O_NONBLOCK);
if(devicehandle == -1) { if (devicehandle == -1)
{
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVD device: Error opening device: %i:%s", errno, strerror(errno)); PrintLog("CDVD device: Error opening device: %i:%s", errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */ #endif /* VERBOSE_WARNINGS */
@ -133,7 +122,8 @@ s32 DeviceOpen() {
// Note: Hmm. Need a minimum capability in case this fails? // Note: Hmm. Need a minimum capability in case this fails?
devicecapability = ioctl(devicehandle, CDROM_GET_CAPABILITY); devicecapability = ioctl(devicehandle, CDROM_GET_CAPABILITY);
if(errno != 0) { if (errno != 0)
{
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVD device: Error getting device capabilities: %i:%s", errno, strerror(errno)); PrintLog("CDVD device: Error getting device capabilities: %i:%s", errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */ #endif /* VERBOSE_WARNINGS */
@ -173,29 +163,26 @@ s32 DeviceOpen() {
// InitDisc(); // InitDisc();
// traystatus = CDVD_TRAY_OPEN; // Start with Tray Open // traystatus = CDVD_TRAY_OPEN; // Start with Tray Open
// DeviceTrayStatus(); // Now find out for sure. // DeviceTrayStatus(); // Now find out for sure.
return(0); // Device opened and ready for use. return(0); // Device opened and ready for use.
} // END DeviceOpen() } // END DeviceOpen()
// Called by DeviceTrayStatus(), CDVDclose(), and CDVDshutdown() // Called by DeviceTrayStatus(), CDVDclose(), and CDVDshutdown()
void DeviceClose() { void DeviceClose()
{
// s32 s32result; // s32 s32result;
int zerospeed; int zerospeed;
zerospeed = 0; zerospeed = 0;
if(devicehandle == -1) { if (devicehandle == -1)
{
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: Device already closed"); PrintLog("CDVD device: Device already closed");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
return; return;
} // ENDIF- Device already closed? Ok. } // ENDIF- Device already closed? Ok.
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DeviceClose()"); PrintLog("CDVD device: DeviceClose()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
InitDisc(); InitDisc();
close(devicehandle); close(devicehandle);
devicehandle = -1; devicehandle = -1;
@ -203,69 +190,73 @@ void DeviceClose() {
return; return;
} // END CDVDclose() } // END CDVDclose()
s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer)
s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer) { {
s32 s32result; s32 s32result;
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DeviceReadTrack(%i)", lsn); PrintLog("CDVD device: DeviceReadTrack(%i)", lsn);
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
if (DiscInserted() == -1) return(-1); if (DiscInserted() == -1) return(-1);
// Get that data // Get that data
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) { if ((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV))
{
s32result = DVDreadTrack(lsn, mode, buffer); s32result = DVDreadTrack(lsn, mode, buffer);
} else { }
else
{
s32result = CDreadTrack(lsn, mode, buffer); s32result = CDreadTrack(lsn, mode, buffer);
} //ENDIF- Read a DVD sector or a CD sector? } //ENDIF- Read a DVD sector or a CD sector?
return(s32result); return(s32result);
} // END DeviceReadTrack() } // END DeviceReadTrack()
s32 DeviceBufferOffset()
s32 DeviceBufferOffset() { {
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DeviceBufferOffset()"); PrintLog("CDVD device: DeviceBufferOffset()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
if (DiscInserted() == -1) return(-1); if (DiscInserted() == -1) return(-1);
if ((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV))
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) { {
return(0); return(0);
} else { }
else
{
return(CDgetBufferOffset()); return(CDgetBufferOffset());
} // ENDIF- Is this a DVD? } // ENDIF- Is this a DVD?
} // END DeviceBufferOffset() } // END DeviceBufferOffset()
s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd)
s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd) { {
if (DiscInserted() == -1) return(-1); if (DiscInserted() == -1) return(-1);
if ((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV))
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) { {
return(DVDgetTD(track, cdvdtd)); return(DVDgetTD(track, cdvdtd));
} else { }
else
{
return(CDgetTD(track, cdvdtd)); return(CDgetTD(track, cdvdtd));
} // ENDIF- Is this a DVD? } // ENDIF- Is this a DVD?
} // END DeviceGetTD() } // END DeviceGetTD()
// Called by DeviceTrayStatus() // Called by DeviceTrayStatus()
s32 DeviceGetDiskType() { s32 DeviceGetDiskType()
{
s32 s32result; s32 s32result;
s32 ioctldisktype; s32 ioctldisktype;
errno = 0; errno = 0;
if(devicehandle == -1) { if (devicehandle == -1)
{
return(-1); return(-1);
} // ENDIF- Someone forget to open the device? } // ENDIF- Someone forget to open the device?
if(traystatus == CDVD_TRAY_OPEN) { if (traystatus == CDVD_TRAY_OPEN)
{
return(disctype); return(disctype);
} // ENDIF- Is the device tray open? No disc to check yet. } // ENDIF- Is the device tray open? No disc to check yet.
if(disctype != CDVD_TYPE_NODISC) { if (disctype != CDVD_TYPE_NODISC)
{
return(disctype); return(disctype);
} // ENDIF- Already checked? Drive still closed? Disc hasn't changed. } // ENDIF- Already checked? Drive still closed? Disc hasn't changed.
@ -273,9 +264,9 @@ s32 DeviceGetDiskType() {
PrintLog("CDVD device: DeviceGetDiskType()"); PrintLog("CDVD device: DeviceGetDiskType()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
disctype = CDVD_TYPE_DETCT; disctype = CDVD_TYPE_DETCT;
ioctldisktype = ioctl(devicehandle, CDROM_DISC_STATUS); ioctldisktype = ioctl(devicehandle, CDROM_DISC_STATUS);
if(errno != 0) { if (errno != 0)
{
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVD device: Trouble reading Disc Type!"); PrintLog("CDVD device: Trouble reading Disc Type!");
PrintLog("CDVD device: Error: %i:%s", errno, strerror(errno)); PrintLog("CDVD device: Error: %i:%s", errno, strerror(errno));
@ -283,24 +274,24 @@ s32 DeviceGetDiskType() {
disctype = CDVD_TYPE_UNKNOWN; disctype = CDVD_TYPE_UNKNOWN;
return(disctype); return(disctype);
} // ENDIF- Trouble probing for a disc? } // ENDIF- Trouble probing for a disc?
s32result = DVDgetDiskType(ioctldisktype); s32result = DVDgetDiskType(ioctldisktype);
if(s32result != -1) { if (s32result != -1)
{
return(disctype); return(disctype);
} // ENDIF- Did we find a disc type? } // ENDIF- Did we find a disc type?
s32result = CDgetDiskType(ioctldisktype); s32result = CDgetDiskType(ioctldisktype);
if(s32result != -1) { if (s32result != -1)
{
return(disctype); return(disctype);
} // ENDIF- Did we find a disc type? } // ENDIF- Did we find a disc type?
disctype = CDVD_TYPE_UNKNOWN; // Not a CD? Not a DVD? Is is peanut butter? disctype = CDVD_TYPE_UNKNOWN; // Not a CD? Not a DVD? Is is peanut butter?
return(disctype); return(disctype);
} // END CDVDgetDiskType() } // END CDVDgetDiskType()
// Called by PollLoop() and CDVDgetTrayStatus() // Called by PollLoop() and CDVDgetTrayStatus()
s32 DeviceTrayStatus() { s32 DeviceTrayStatus()
{
s32 s32result; s32 s32result;
errno = 0; errno = 0;
@ -309,13 +300,16 @@ s32 DeviceTrayStatus() {
PrintLog("CDVD device: DeviceTrayStatus()"); PrintLog("CDVD device: DeviceTrayStatus()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
if(devicehandle == -1) { if (devicehandle == -1)
{
return(-1); return(-1);
} // ENDIF- Someone forget to open the device? } // ENDIF- Someone forget to open the device?
if((devicecapability & CDC_DRIVE_STATUS) != 0) { if ((devicecapability & CDC_DRIVE_STATUS) != 0)
{
s32result = ioctl(devicehandle, CDROM_DRIVE_STATUS); s32result = ioctl(devicehandle, CDROM_DRIVE_STATUS);
if(s32result < 0) { if (s32result < 0)
{
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVD device: Trouble reading Drive Status!"); PrintLog("CDVD device: Trouble reading Drive Status!");
PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno)); PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno));
@ -323,10 +317,12 @@ s32 DeviceTrayStatus() {
s32result = CDS_TRAY_OPEN; s32result = CDS_TRAY_OPEN;
} // ENDIF- Failure to get status? Assume it's open. } // ENDIF- Failure to get status? Assume it's open.
errno = 0; errno = 0;
}
} else { else
{
s32result = ioctl(devicehandle, CDROM_DISC_STATUS); s32result = ioctl(devicehandle, CDROM_DISC_STATUS);
if(errno != 0) { if (errno != 0)
{
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVD device: Trouble detecting Disc Status presense!"); PrintLog("CDVD device: Trouble detecting Disc Status presense!");
PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno)); PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno));
@ -334,82 +330,83 @@ s32 DeviceTrayStatus() {
s32result = CDS_TRAY_OPEN; s32result = CDS_TRAY_OPEN;
errno = 0; errno = 0;
} // ENDIF- Trouble? } // ENDIF- Trouble?
if(s32result == CDS_NO_DISC) { if (s32result == CDS_NO_DISC)
{
s32result = CDS_TRAY_OPEN; s32result = CDS_TRAY_OPEN;
} // ENDIF- Is there no disc in the device? Guess the tray is open } // ENDIF- Is there no disc in the device? Guess the tray is open
} // ENDIF- Can we poll the tray directly? (Or look at disc status instead?) } // ENDIF- Can we poll the tray directly? (Or look at disc status instead?)
if (s32result == CDS_TRAY_OPEN)
if(s32result == CDS_TRAY_OPEN) { {
traystatus = CDVD_TRAY_OPEN; traystatus = CDVD_TRAY_OPEN;
if(disctype != CDVD_TYPE_NODISC) { if (disctype != CDVD_TYPE_NODISC)
{
DeviceClose(); // Kind of severe way of flushing all buffers. DeviceClose(); // Kind of severe way of flushing all buffers.
DeviceOpen(); DeviceOpen();
InitDisc(); InitDisc();
} // ENDIF- Tray just opened... clear disc info } // ENDIF- Tray just opened... clear disc info
} else { }
else
{
traystatus = CDVD_TRAY_CLOSE; traystatus = CDVD_TRAY_CLOSE;
if(disctype == CDVD_TYPE_NODISC) { if (disctype == CDVD_TYPE_NODISC)
{
DeviceGetDiskType(); DeviceGetDiskType();
} // ENDIF- Tray just closed? Get disc information } // ENDIF- Tray just closed? Get disc information
} // ENDIF- Do we detect an open tray? } // ENDIF- Do we detect an open tray?
return(traystatus); return(traystatus);
} // END CDVD_getTrayStatus() } // END CDVD_getTrayStatus()
s32 DeviceTrayOpen()
{
s32 DeviceTrayOpen() {
s32 s32result; s32 s32result;
errno = 0; errno = 0;
if(devicehandle == -1) { if (devicehandle == -1)
{
return(-1); return(-1);
} // ENDIF- Someone forget to open the device? } // ENDIF- Someone forget to open the device?
if((devicecapability & CDC_OPEN_TRAY) == 0) { if ((devicecapability & CDC_OPEN_TRAY) == 0)
{
return(-1); return(-1);
} // ENDIF- Don't have open capability? Error out. } // ENDIF- Don't have open capability? Error out.
// Tray already open? Exit. // Tray already open? Exit.
if (traystatus == CDVD_TRAY_OPEN) return(0); if (traystatus == CDVD_TRAY_OPEN) return(0);
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DeviceTrayOpen()"); PrintLog("CDVD device: DeviceTrayOpen()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
s32result = ioctl(devicehandle, CDROMEJECT); s32result = ioctl(devicehandle, CDROMEJECT);
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
if((s32result != 0) || (errno != 0)) { if ((s32result != 0) || (errno != 0))
{
PrintLog("CDVD device: Could not open the tray!"); PrintLog("CDVD device: Could not open the tray!");
PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno)); PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno));
} // ENDIF- Trouble? } // ENDIF- Trouble?
#endif /* VERBOSE_WARNINGS */ #endif /* VERBOSE_WARNINGS */
return(s32result); return(s32result);
} // END DeviceTrayOpen() } // END DeviceTrayOpen()
s32 DeviceTrayClose()
{
s32 DeviceTrayClose() {
s32 s32result; s32 s32result;
errno = 0; errno = 0;
if (devicehandle == -1)
if(devicehandle == -1) { {
return(-1); return(-1);
} // ENDIF- Someone forget to open the device? } // ENDIF- Someone forget to open the device?
if ((devicecapability & CDC_CLOSE_TRAY) == 0)
if((devicecapability & CDC_CLOSE_TRAY) == 0) { {
return(-1); return(-1);
} // ENDIF- Don't have close capability? Error out. } // ENDIF- Don't have close capability? Error out.
// Tray already closed? Exit. // Tray already closed? Exit.
if (traystatus == CDVD_TRAY_CLOSE) return(0); if (traystatus == CDVD_TRAY_CLOSE) return(0);
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DeviceTrayClose()"); PrintLog("CDVD device: DeviceTrayClose()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
s32result = ioctl(devicehandle, CDROMCLOSETRAY); s32result = ioctl(devicehandle, CDROMCLOSETRAY);
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
if((s32result != 0) || (errno != 0)) { if ((s32result != 0) || (errno != 0))
{
PrintLog("CDVD device: Could not close the tray!"); PrintLog("CDVD device: Could not close the tray!");
PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno)); PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno));
} // ENDIF- Trouble? } // ENDIF- Trouble?

View File

@ -1,138 +1,60 @@
/* device.h /* device.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef __DEVICE_H__ #ifndef __DEVICE_H__
#define __DEVICE_H__ #define __DEVICE_H__
#include <time.h> // time_t #include <time.h> // time_t
#ifndef __LINUX__ #ifndef __LINUX__
#ifdef __linux__ #ifdef __linux__
#define __LINUX__ #define __LINUX__
#endif /* __linux__ */ #endif /* __linux__ */
#endif /* No __LINUX__ */ #endif /* No __LINUX__ */
#define CDVDdefs #define CDVDdefs
#include "../PS2Edefs.h" #include "../PS2Edefs.h"
// #define VERBOSE_FUNCTION_DEVICE // #define VERBOSE_FUNCTION_DEVICE
// #define VERBOSE_WARNINGS // #define VERBOSE_WARNINGS
#define VERBOSE_DISC_TYPE #define VERBOSE_DISC_TYPE
#define VERBOSE_DISC_INFO #define VERBOSE_DISC_INFO
// Device Data // Device Data
extern int devicehandle; extern int devicehandle;
extern s32 devicecapability; // Need to export? extern s32 devicecapability; // Need to export?
extern time_t lasttime; extern time_t lasttime;
extern s32 traystatus; extern s32 traystatus;
extern s32 disctype; extern s32 disctype;
extern u8 tocbuffer[]; extern u8 tocbuffer[];
// Device Functions // Device Functions
extern void DeviceInit(); extern void DeviceInit();
extern void InitDisc(); extern void InitDisc();
extern s32 DiscInserted(); extern s32 DiscInserted();
extern s32 DeviceOpen(); extern s32 DeviceOpen();
extern void DeviceClose(); extern void DeviceClose();
extern s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer); extern s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 DeviceBufferOffset(); extern s32 DeviceBufferOffset();
extern s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd); extern s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd);
extern s32 DeviceGetDiskType(); extern s32 DeviceGetDiskType();
extern s32 DeviceTrayStatus(); extern s32 DeviceTrayStatus();
extern s32 DeviceTrayOpen(); extern s32 DeviceTrayOpen();
extern s32 DeviceTrayClose(); extern s32 DeviceTrayClose();
#endif /* __DEVICE_H__ */ #endif /* __DEVICE_H__ */

View File

@ -1,886 +1,475 @@
/* devicebox.c /* devicebox.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <string.h> // strcpy() #include <string.h> // strcpy()
#include <sys/stat.h> // stat() #include <sys/stat.h> // stat()
#include <sys/types.h> // stat() #include <sys/types.h> // stat()
#include <unistd.h> // stat() #include <unistd.h> // stat()
#include <gtk/gtkbutton.h> // gtk_button_new_with_label() #include <gtk/gtkbutton.h> // gtk_button_new_with_label()
#include <gtk/gtkcombobox.h> // gtk_combo_box_new() #include <gtk/gtkcombobox.h> // gtk_combo_box_new()
#include <gtk/gtkcheckbutton.h> // gtk_check_button_new() #include <gtk/gtkcheckbutton.h> // gtk_check_button_new()
#include <gtk/gtkcontainer.h> // gtk_container_add() #include <gtk/gtkcontainer.h> // gtk_container_add()
#include <gtk/gtkentry.h> // gtk_entry_new() #include <gtk/gtkentry.h> // gtk_entry_new()
#include <gtk/gtkfilesel.h> // gtk_file_selection_set_filename() #include <gtk/gtkfilesel.h> // gtk_file_selection_set_filename()
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new() #include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
#include <gtk/gtkhbox.h> // gtk_hbox_new() #include <gtk/gtkhbox.h> // gtk_hbox_new()
#include <gtk/gtkhseparator.h> // gtk_hseparator_new() #include <gtk/gtkhseparator.h> // gtk_hseparator_new()
#include <gtk/gtklabel.h> // gtk_label_new() #include <gtk/gtklabel.h> // gtk_label_new()
#include <gtk/gtkmain.h> // gtk_main_iteration() #include <gtk/gtkmain.h> // gtk_main_iteration()
#include <gtk/gtktogglebutton.h> // gtk_toggle_button_get_active() #include <gtk/gtktogglebutton.h> // gtk_toggle_button_get_active()
#include <gtk/gtkvbox.h> // gtk_vbox_new() #include <gtk/gtkvbox.h> // gtk_vbox_new()
#include <gtk/gtkwindow.h> // gtk_window_new() #include <gtk/gtkwindow.h> // gtk_window_new()
#ifndef __LINUX__ #ifndef __LINUX__
#ifdef __linux__ #ifdef __linux__
#define __LINUX__ #define __LINUX__
#endif /* __linux__ */ #endif /* __linux__ */
#endif /* No __LINUX__ */ #endif /* No __LINUX__ */
#define CDVDdefs #define CDVDdefs
#include "PS2Edefs.h" #include "PS2Edefs.h"
#include "conf.h" #include "conf.h"
#include "device.h" #include "device.h"
#include "isofile.h" #include "isofile.h"
#include "isocompress.h" // compressdesc[] #include "isocompress.h" // compressdesc[]
// #include "imagetype.h" // imagedata[].name // #include "imagetype.h" // imagedata[].name
#include "multifile.h" // multinames[] #include "multifile.h" // multinames[]
#include "toc.h" #include "toc.h"
#include "progressbox.h" #include "progressbox.h"
#include "messagebox.h" #include "messagebox.h"
#include "selectionbox.h" #include "selectionbox.h"
#include "mainbox.h" #include "mainbox.h"
#include "devicebox.h" #include "devicebox.h"
struct DeviceBoxData devicebox; struct DeviceBoxData devicebox;
void DeviceBoxDestroy()
{
if (devicebox.window != NULL)
void DeviceBoxDestroy() { {
if(devicebox.window != NULL) {
gtk_widget_destroy(devicebox.window); gtk_widget_destroy(devicebox.window);
devicebox.window = NULL; devicebox.window = NULL;
devicebox.device = NULL; devicebox.device = NULL;
devicebox.devicedesc = NULL; devicebox.devicedesc = NULL;
devicebox.file = NULL; devicebox.file = NULL;
devicebox.selectbutton = NULL; devicebox.selectbutton = NULL;
devicebox.filedesc = NULL; devicebox.filedesc = NULL;
devicebox.compress = NULL; devicebox.compress = NULL;
devicebox.multi = NULL; devicebox.multi = NULL;
devicebox.okbutton = NULL; devicebox.okbutton = NULL;
devicebox.cancelbutton = NULL; devicebox.cancelbutton = NULL;
} // ENDIF- Do we have a Main Window still? } // ENDIF- Do we have a Main Window still?
} // END DeviceBoxDestroy() } // END DeviceBoxDestroy()
void DeviceBoxUnfocus()
{
void DeviceBoxUnfocus() {
gtk_widget_set_sensitive(devicebox.device, FALSE); gtk_widget_set_sensitive(devicebox.device, FALSE);
gtk_widget_set_sensitive(devicebox.file, FALSE); gtk_widget_set_sensitive(devicebox.file, FALSE);
gtk_widget_set_sensitive(devicebox.selectbutton, FALSE); gtk_widget_set_sensitive(devicebox.selectbutton, FALSE);
gtk_widget_set_sensitive(devicebox.compress, FALSE); gtk_widget_set_sensitive(devicebox.compress, FALSE);
gtk_widget_set_sensitive(devicebox.multi, FALSE); gtk_widget_set_sensitive(devicebox.multi, FALSE);
gtk_widget_set_sensitive(devicebox.okbutton, FALSE); gtk_widget_set_sensitive(devicebox.okbutton, FALSE);
gtk_widget_set_sensitive(devicebox.cancelbutton, FALSE); gtk_widget_set_sensitive(devicebox.cancelbutton, FALSE);
gtk_widget_hide(devicebox.window); gtk_widget_hide(devicebox.window);
// gtk_window_iconify(GTK_WINDOW(devicebox.window)); // gtk_window_iconify(GTK_WINDOW(devicebox.window));
} // END DeviceBoxUnfocus() } // END DeviceBoxUnfocus()
gint DeviceBoxDeviceEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint DeviceBoxDeviceEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
struct stat filestat; struct stat filestat;
int returnval; int returnval;
returnval = stat(gtk_entry_get_text(GTK_ENTRY(devicebox.device)), &filestat); returnval = stat(gtk_entry_get_text(GTK_ENTRY(devicebox.device)), &filestat);
if (returnval == -1)
if(returnval == -1) { {
gtk_label_set_text(GTK_LABEL(devicebox.devicedesc), "Device Type: ---"); gtk_label_set_text(GTK_LABEL(devicebox.devicedesc), "Device Type: ---");
return(TRUE); return(TRUE);
} // ENDIF- Not a name of any sort? } // ENDIF- Not a name of any sort?
if (S_ISDIR(filestat.st_mode) != 0)
{
if(S_ISDIR(filestat.st_mode) != 0) {
gtk_label_set_text(GTK_LABEL(devicebox.devicedesc), "Device Type: Not a device"); gtk_label_set_text(GTK_LABEL(devicebox.devicedesc), "Device Type: Not a device");
return(TRUE); return(TRUE);
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
gtk_label_set_text(GTK_LABEL(devicebox.devicedesc), "Device Type: Device Likely"); gtk_label_set_text(GTK_LABEL(devicebox.devicedesc), "Device Type: Device Likely");
return(TRUE); return(TRUE);
} // END DeviceBoxDeviceEvent() } // END DeviceBoxDeviceEvent()
gint DeviceBoxFileEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint DeviceBoxFileEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
int returnval; int returnval;
char templine[256]; char templine[256];
struct IsoFile *tempfile; struct IsoFile *tempfile;
returnval = IsIsoFile(gtk_entry_get_text(GTK_ENTRY(devicebox.file))); returnval = IsIsoFile(gtk_entry_get_text(GTK_ENTRY(devicebox.file)));
if (returnval == -1)
if(returnval == -1) { {
gtk_label_set_text(GTK_LABEL(devicebox.filedesc), "File Type: ---"); gtk_label_set_text(GTK_LABEL(devicebox.filedesc), "File Type: ---");
return(TRUE); return(TRUE);
} // ENDIF- Not a name of any sort? } // ENDIF- Not a name of any sort?
if (returnval == -2)
{
if(returnval == -2) {
gtk_label_set_text(GTK_LABEL(devicebox.filedesc), "File Type: Not a file"); gtk_label_set_text(GTK_LABEL(devicebox.filedesc), "File Type: Not a file");
return(TRUE); return(TRUE);
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
if (returnval == -3)
{
if(returnval == -3) {
gtk_label_set_text(GTK_LABEL(devicebox.filedesc), "File Type: Not a valid image file"); gtk_label_set_text(GTK_LABEL(devicebox.filedesc), "File Type: Not a valid image file");
return(TRUE); return(TRUE);
} // ENDIF- Not an image file? } // ENDIF- Not an image file?
if (returnval == -4)
{
if(returnval == -4) {
gtk_label_set_text(GTK_LABEL(devicebox.filedesc), "File Type: Missing Table File (will rebuild)"); gtk_label_set_text(GTK_LABEL(devicebox.filedesc), "File Type: Missing Table File (will rebuild)");
return(TRUE); return(TRUE);
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
tempfile = IsoFileOpenForRead(gtk_entry_get_text(GTK_ENTRY(devicebox.file))); tempfile = IsoFileOpenForRead(gtk_entry_get_text(GTK_ENTRY(devicebox.file)));
sprintf(templine, "File Type: %s%s%s", sprintf(templine, "File Type: %s%s%s",
multinames[tempfile->multi], multinames[tempfile->multi],
tempfile->imagename, tempfile->imagename,
compressdesc[tempfile->compress]); compressdesc[tempfile->compress]);
gtk_label_set_text(GTK_LABEL(devicebox.filedesc), templine); gtk_label_set_text(GTK_LABEL(devicebox.filedesc), templine);
tempfile = IsoFileClose(tempfile); tempfile = IsoFileClose(tempfile);
return(TRUE); return(TRUE);
} // END DeviceBoxFileEvent() } // END DeviceBoxFileEvent()
void DeviceBoxRefocus()
{
void DeviceBoxRefocus() {
GdkEvent event; GdkEvent event;
DeviceBoxDeviceEvent(NULL, event, NULL); DeviceBoxDeviceEvent(NULL, event, NULL);
DeviceBoxFileEvent(NULL, event, NULL); DeviceBoxFileEvent(NULL, event, NULL);
gtk_widget_set_sensitive(devicebox.device, TRUE); gtk_widget_set_sensitive(devicebox.device, TRUE);
gtk_widget_set_sensitive(devicebox.file, TRUE); gtk_widget_set_sensitive(devicebox.file, TRUE);
gtk_widget_set_sensitive(devicebox.selectbutton, TRUE); gtk_widget_set_sensitive(devicebox.selectbutton, TRUE);
gtk_widget_set_sensitive(devicebox.compress, TRUE); gtk_widget_set_sensitive(devicebox.compress, TRUE);
gtk_widget_set_sensitive(devicebox.multi, TRUE); gtk_widget_set_sensitive(devicebox.multi, TRUE);
gtk_widget_set_sensitive(devicebox.okbutton, TRUE); gtk_widget_set_sensitive(devicebox.okbutton, TRUE);
gtk_widget_set_sensitive(devicebox.cancelbutton, TRUE); gtk_widget_set_sensitive(devicebox.cancelbutton, TRUE);
gtk_window_set_focus(GTK_WINDOW(devicebox.window), devicebox.file); gtk_window_set_focus(GTK_WINDOW(devicebox.window), devicebox.file);
gtk_widget_show_all(devicebox.window); gtk_widget_show_all(devicebox.window);
gtk_window_deiconify(GTK_WINDOW(devicebox.window)); gtk_window_deiconify(GTK_WINDOW(devicebox.window));
} // END DeviceBoxRefocus() } // END DeviceBoxRefocus()
gint DeviceBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint DeviceBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
gtk_widget_hide(devicebox.window); gtk_widget_hide(devicebox.window);
MainBoxRefocus(); MainBoxRefocus();
return(TRUE); return(TRUE);
} // END DeviceBoxCancelEvent() } // END DeviceBoxCancelEvent()
gint DeviceBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint DeviceBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
char templine[256]; char templine[256];
u8 tempbuffer[2352]; u8 tempbuffer[2352];
struct IsoFile *tofile; struct IsoFile *tofile;
const char *tempdevice; const char *tempdevice;
s32 retval; s32 retval;
cdvdTD cdvdtd; cdvdTD cdvdtd;
int stop; int stop;
int compressmethod; int compressmethod;
int multi; int multi;
int imagetype; int imagetype;
int i; int i;
DeviceBoxUnfocus(); DeviceBoxUnfocus();
tempdevice = gtk_entry_get_text(GTK_ENTRY(devicebox.device)); tempdevice = gtk_entry_get_text(GTK_ENTRY(devicebox.device));
strcpy(conf.devicename, tempdevice); // Temporarily put in new device name strcpy(conf.devicename, tempdevice); // Temporarily put in new device name
tempdevice = NULL; tempdevice = NULL;
retval = DeviceOpen(); retval = DeviceOpen();
if (retval != 0)
if(retval != 0) { {
DeviceClose(); DeviceClose();
MessageBoxShow("Could not open the device", 2); MessageBoxShow("Could not open the device", 2);
return(TRUE); return(TRUE);
} // ENDIF- Trouble opening device? Abort here. } // ENDIF- Trouble opening device? Abort here.
DeviceTrayStatus(); DeviceTrayStatus();
retval = DiscInserted(); retval = DiscInserted();
if (retval != 0)
if(retval != 0) { {
DeviceClose(); DeviceClose();
MessageBoxShow("No disc in the device\r\nPlease put a disc in and try again.", 2); MessageBoxShow("No disc in the device\r\nPlease put a disc in and try again.", 2);
return(TRUE); return(TRUE);
} // ENDIF- Trouble opening device? Abort here. } // ENDIF- Trouble opening device? Abort here.
retval = DeviceGetTD(0, &cdvdtd); // Fish for Ending Sector retval = DeviceGetTD(0, &cdvdtd); // Fish for Ending Sector
if (retval < 0)
if(retval < 0) { {
DeviceClose(); DeviceClose();
MessageBoxShow("Could not retrieve disc sector size", 2); MessageBoxShow("Could not retrieve disc sector size", 2);
return(TRUE); return(TRUE);
} // ENDIF- Trouble getting disc sector count? } // ENDIF- Trouble getting disc sector count?
compressmethod = gtk_combo_box_get_active(GTK_COMBO_BOX(devicebox.compress)); compressmethod = gtk_combo_box_get_active(GTK_COMBO_BOX(devicebox.compress));
if (compressmethod > 0) compressmethod += 2; if (compressmethod > 0) compressmethod += 2;
multi = 0; multi = 0;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(devicebox.multi)) == TRUE) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(devicebox.multi)) == TRUE)
multi = 1; multi = 1;
imagetype = 0; imagetype = 0;
if ((disctype != CDVD_TYPE_PS2DVD) && if ((disctype != CDVD_TYPE_PS2DVD) &&
(disctype != CDVD_TYPE_DVDV)) imagetype = 8; (disctype != CDVD_TYPE_DVDV)) imagetype = 8;
tofile = IsoFileOpenForWrite(gtk_entry_get_text(GTK_ENTRY(devicebox.file)), tofile = IsoFileOpenForWrite(gtk_entry_get_text(GTK_ENTRY(devicebox.file)),
imagetype, imagetype,
multi, multi,
compressmethod); compressmethod);
if (tofile == NULL)
if(tofile == NULL) { {
DeviceClose(); DeviceClose();
MessageBoxShow("Could not create the new ISO file", 2); MessageBoxShow("Could not create the new ISO file", 2);
return(TRUE); return(TRUE);
} // ENDIF- Trouble opening the ISO file? } // ENDIF- Trouble opening the ISO file?
// Open Progress Bar // Open Progress Bar
sprintf(templine, "%s -> %s", sprintf(templine, "%s -> %s",
gtk_entry_get_text(GTK_ENTRY(devicebox.device)), tofile->name); gtk_entry_get_text(GTK_ENTRY(devicebox.device)), tofile->name);
ProgressBoxStart(templine, (off64_t) cdvdtd.lsn); ProgressBoxStart(templine, (off64_t) cdvdtd.lsn);
tofile->cdvdtype = disctype; tofile->cdvdtype = disctype;
for (i = 0; i < 2048; i++) tofile->toc[i] = tocbuffer[i]; for (i = 0; i < 2048; i++) tofile->toc[i] = tocbuffer[i];
stop = 0; stop = 0;
mainbox.stop = 0; mainbox.stop = 0;
progressbox.stop = 0; progressbox.stop = 0;
while ((stop == 0) && (tofile->sectorpos < cdvdtd.lsn))
while((stop == 0) && (tofile->sectorpos < cdvdtd.lsn)) { {
if (imagetype == 0)
if(imagetype == 0) { {
retval = DeviceReadTrack((u32) tofile->sectorpos, retval = DeviceReadTrack((u32) tofile->sectorpos,
CDVD_MODE_2048, CDVD_MODE_2048,
tempbuffer); tempbuffer);
}
} else { else
{
retval = DeviceReadTrack((u32) tofile->sectorpos, retval = DeviceReadTrack((u32) tofile->sectorpos,
CDVD_MODE_2352, CDVD_MODE_2352,
tempbuffer); tempbuffer);
} // ENDIF- Are we reading a DVD sector? (Or a CD sector?) } // ENDIF- Are we reading a DVD sector? (Or a CD sector?)
if (retval < 0)
if(retval < 0) { {
for (i = 0; i < 2352; i++)
for(i = 0; i < 2352; i++) { {
tempbuffer[i] = 0; tempbuffer[i] = 0;
} // NEXT i- Zeroing the buffer } // NEXT i- Zeroing the buffer
} // ENDIF- Trouble reading next block? } // ENDIF- Trouble reading next block?
retval = IsoFileWrite(tofile, tempbuffer); retval = IsoFileWrite(tofile, tempbuffer);
if (retval < 0)
if(retval < 0) { {
MessageBoxShow("Trouble writing new file", 3); MessageBoxShow("Trouble writing new file", 3);
stop = 1; stop = 1;
} // ENDIF- Trouble writing out the next block? } // ENDIF- Trouble writing out the next block?
ProgressBoxTick(tofile->sectorpos); ProgressBoxTick(tofile->sectorpos);
while (gtk_events_pending()) gtk_main_iteration(); while (gtk_events_pending()) gtk_main_iteration();
if (mainbox.stop != 0) stop = 2; if (mainbox.stop != 0) stop = 2;
if (progressbox.stop != 0) stop = 2; if (progressbox.stop != 0) stop = 2;
} // ENDWHILE- No reason found to stop... } // ENDWHILE- No reason found to stop...
ProgressBoxStop(); ProgressBoxStop();
if (stop == 0)
{
if(stop == 0) {
if (tofile->multi == 1) tofile->name[tofile->multipos] = '0'; // First file if (tofile->multi == 1) tofile->name[tofile->multipos] = '0'; // First file
strcpy(templine, tofile->name); strcpy(templine, tofile->name);
} // ENDIF- Did we succeed with the transfer? } // ENDIF- Did we succeed with the transfer?
DeviceClose(); DeviceClose();
if (stop == 0)
if(stop == 0) { {
IsoSaveTOC(tofile); IsoSaveTOC(tofile);
tofile = IsoFileClose(tofile); tofile = IsoFileClose(tofile);
gtk_entry_set_text(GTK_ENTRY(mainbox.file), templine); gtk_entry_set_text(GTK_ENTRY(mainbox.file), templine);
}
} else { else
{
tofile = IsoFileCloseAndDelete(tofile); tofile = IsoFileCloseAndDelete(tofile);
} // ENDIF- (Failed to complete writing file? Get rid of the garbage files.) } // ENDIF- (Failed to complete writing file? Get rid of the garbage files.)
if (stop != 1) DeviceBoxRefocus(); if (stop != 1) DeviceBoxRefocus();
if (stop == 0) DeviceBoxCancelEvent(widget, event, data); if (stop == 0) DeviceBoxCancelEvent(widget, event, data);
return(TRUE); return(TRUE);
} // END DeviceBoxOKEvent() } // END DeviceBoxOKEvent()
gint DeviceBoxBrowseEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint DeviceBoxBrowseEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
DeviceBoxUnfocus(); DeviceBoxUnfocus();
// Transfer file name to file selection // Transfer file name to file selection
gtk_file_selection_set_filename(GTK_FILE_SELECTION(selectionbox.window), gtk_file_selection_set_filename(GTK_FILE_SELECTION(selectionbox.window),
gtk_entry_get_text(GTK_ENTRY(devicebox.file))); gtk_entry_get_text(GTK_ENTRY(devicebox.file)));
selectionbox.wherefrom = 2; // From the Device Window selectionbox.wherefrom = 2; // From the Device Window
SelectionBoxRefocus(); SelectionBoxRefocus();
return(TRUE); return(TRUE);
} // END DeviceBoxBrowseEvent() } // END DeviceBoxBrowseEvent()
void DeviceBoxDisplay()
{
void DeviceBoxDisplay() {
GtkWidget *item; GtkWidget *item;
GtkWidget *hbox1; GtkWidget *hbox1;
GtkWidget *vbox1; GtkWidget *vbox1;
int nameptr; int nameptr;
devicebox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); devicebox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(devicebox.window), 5); gtk_container_set_border_width(GTK_CONTAINER(devicebox.window), 5);
gtk_window_set_title(GTK_WINDOW(devicebox.window), "CDVDisoEFP ISO Creation"); gtk_window_set_title(GTK_WINDOW(devicebox.window), "CDVDisoEFP ISO Creation");
gtk_window_set_position(GTK_WINDOW(devicebox.window), GTK_WIN_POS_CENTER); gtk_window_set_position(GTK_WINDOW(devicebox.window), GTK_WIN_POS_CENTER);
g_signal_connect(G_OBJECT(devicebox.window), "delete_event", g_signal_connect(G_OBJECT(devicebox.window), "delete_event",
G_CALLBACK(DeviceBoxCancelEvent), NULL); G_CALLBACK(DeviceBoxCancelEvent), NULL);
vbox1 = gtk_vbox_new(FALSE, 5); vbox1 = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(devicebox.window), vbox1); gtk_container_add(GTK_CONTAINER(devicebox.window), vbox1);
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5); gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
gtk_widget_show(vbox1); gtk_widget_show(vbox1);
hbox1 = gtk_hbox_new(FALSE, 10); hbox1 = gtk_hbox_new(FALSE, 10);
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
item = gtk_label_new("Source CD/DVD Device:"); item = gtk_label_new("Source CD/DVD Device:");
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
devicebox.device = gtk_entry_new(); devicebox.device = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox1), devicebox.device, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), devicebox.device, TRUE, TRUE, 0);
gtk_widget_show(devicebox.device); gtk_widget_show(devicebox.device);
g_signal_connect(G_OBJECT(devicebox.device), "changed", g_signal_connect(G_OBJECT(devicebox.device), "changed",
G_CALLBACK(DeviceBoxDeviceEvent), NULL); G_CALLBACK(DeviceBoxDeviceEvent), NULL);
hbox1 = NULL; hbox1 = NULL;
devicebox.devicedesc = gtk_label_new("Device Type: ---"); devicebox.devicedesc = gtk_label_new("Device Type: ---");
gtk_box_pack_start(GTK_BOX(vbox1), devicebox.devicedesc, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), devicebox.devicedesc, FALSE, FALSE, 0);
gtk_widget_show(devicebox.devicedesc); gtk_widget_show(devicebox.devicedesc);
item = gtk_hseparator_new(); item = gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(vbox1), item, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), item, TRUE, TRUE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
hbox1 = gtk_hbox_new(FALSE, 10); hbox1 = gtk_hbox_new(FALSE, 10);
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
item = gtk_label_new("Iso File:"); item = gtk_label_new("Iso File:");
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
devicebox.file = gtk_entry_new(); devicebox.file = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox1), devicebox.file, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), devicebox.file, TRUE, TRUE, 0);
gtk_widget_show(devicebox.file); gtk_widget_show(devicebox.file);
g_signal_connect(G_OBJECT(devicebox.file), "changed", g_signal_connect(G_OBJECT(devicebox.file), "changed",
G_CALLBACK(DeviceBoxFileEvent), NULL); G_CALLBACK(DeviceBoxFileEvent), NULL);
devicebox.selectbutton = gtk_button_new_with_label("Browse"); devicebox.selectbutton = gtk_button_new_with_label("Browse");
gtk_box_pack_start(GTK_BOX(hbox1), devicebox.selectbutton, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), devicebox.selectbutton, FALSE, FALSE, 0);
gtk_widget_show(devicebox.selectbutton); gtk_widget_show(devicebox.selectbutton);
g_signal_connect(G_OBJECT(devicebox.selectbutton), "clicked", g_signal_connect(G_OBJECT(devicebox.selectbutton), "clicked",
G_CALLBACK(DeviceBoxBrowseEvent), NULL); G_CALLBACK(DeviceBoxBrowseEvent), NULL);
hbox1 = NULL; hbox1 = NULL;
devicebox.filedesc = gtk_label_new("File Type: ---"); devicebox.filedesc = gtk_label_new("File Type: ---");
gtk_box_pack_start(GTK_BOX(vbox1), devicebox.filedesc, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), devicebox.filedesc, FALSE, FALSE, 0);
gtk_widget_show(devicebox.filedesc); gtk_widget_show(devicebox.filedesc);
hbox1 = gtk_hbox_new(FALSE, 10); hbox1 = gtk_hbox_new(FALSE, 10);
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
item = gtk_label_new("New File Compression:"); item = gtk_label_new("New File Compression:");
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
devicebox.compress = gtk_combo_box_new_text(); devicebox.compress = gtk_combo_box_new_text();
gtk_box_pack_start(GTK_BOX(hbox1), devicebox.compress, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), devicebox.compress, FALSE, FALSE, 0);
nameptr = 0; nameptr = 0;
while (compressnames[nameptr] != NULL)
while(compressnames[nameptr] != NULL) { {
gtk_combo_box_append_text(GTK_COMBO_BOX(devicebox.compress), gtk_combo_box_append_text(GTK_COMBO_BOX(devicebox.compress),
compressnames[nameptr]); compressnames[nameptr]);
nameptr++; nameptr++;
} // ENDWHILE- loading compression types into combo box } // ENDWHILE- loading compression types into combo box
gtk_combo_box_set_active(GTK_COMBO_BOX(devicebox.compress), 0); // Temp Line gtk_combo_box_set_active(GTK_COMBO_BOX(devicebox.compress), 0); // Temp Line
gtk_widget_show(devicebox.compress); gtk_widget_show(devicebox.compress);
hbox1 = NULL; hbox1 = NULL;
hbox1 = gtk_hbox_new(FALSE, 10); hbox1 = gtk_hbox_new(FALSE, 10);
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
item = gtk_label_new("Multiple Files (all under 2 GB):"); item = gtk_label_new("Multiple Files (all under 2 GB):");
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
devicebox.multi = gtk_check_button_new(); devicebox.multi = gtk_check_button_new();
gtk_box_pack_start(GTK_BOX(hbox1), devicebox.multi, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), devicebox.multi, FALSE, FALSE, 0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(devicebox.multi), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(devicebox.multi), FALSE);
gtk_widget_show(devicebox.multi); gtk_widget_show(devicebox.multi);
hbox1 = NULL; hbox1 = NULL;
hbox1 = gtk_hbutton_box_new(); hbox1 = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
devicebox.okbutton = gtk_button_new_with_label("Make File"); devicebox.okbutton = gtk_button_new_with_label("Make File");
gtk_box_pack_start(GTK_BOX(hbox1), devicebox.okbutton, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), devicebox.okbutton, TRUE, TRUE, 0);
gtk_widget_show(devicebox.okbutton); gtk_widget_show(devicebox.okbutton);
g_signal_connect(G_OBJECT(devicebox.okbutton), "clicked", g_signal_connect(G_OBJECT(devicebox.okbutton), "clicked",
G_CALLBACK(DeviceBoxOKEvent), NULL); G_CALLBACK(DeviceBoxOKEvent), NULL);
devicebox.cancelbutton = gtk_button_new_with_label("Cancel"); devicebox.cancelbutton = gtk_button_new_with_label("Cancel");
gtk_box_pack_start(GTK_BOX(hbox1), devicebox.cancelbutton, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), devicebox.cancelbutton, TRUE, TRUE, 0);
gtk_widget_show(devicebox.cancelbutton); gtk_widget_show(devicebox.cancelbutton);
g_signal_connect(G_OBJECT(devicebox.cancelbutton), "clicked", g_signal_connect(G_OBJECT(devicebox.cancelbutton), "clicked",
G_CALLBACK(DeviceBoxCancelEvent), NULL); G_CALLBACK(DeviceBoxCancelEvent), NULL);
hbox1 = NULL; hbox1 = NULL;
vbox1 = NULL; vbox1 = NULL;
// Device text not set until now to get the correct description. // Device text not set until now to get the correct description.
gtk_entry_set_text(GTK_ENTRY(devicebox.device), conf.devicename); gtk_entry_set_text(GTK_ENTRY(devicebox.device), conf.devicename);
DeviceInit(); // Initialize device access DeviceInit(); // Initialize device access
} // END DeviceBoxDisplay() } // END DeviceBoxDisplay()

View File

@ -1,100 +1,47 @@
/* devicebox.h /* devicebox.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef DEVICEBOX_H #ifndef DEVICEBOX_H
#define DEVICEBOX_H #define DEVICEBOX_H
#include <gtk/gtkwidget.h> #include <gtk/gtkwidget.h>
struct DeviceBoxData
{
struct DeviceBoxData {
GtkWidget *window; // GtkWindow GtkWidget *window; // GtkWindow
GtkWidget *device; // GtkEntry GtkWidget *device; // GtkEntry
GtkWidget *devicedesc; // GtkLabel GtkWidget *devicedesc; // GtkLabel
GtkWidget *file; // GtkEntry GtkWidget *file; // GtkEntry
GtkWidget *selectbutton; // GtkButton GtkWidget *selectbutton; // GtkButton
GtkWidget *filedesc; // GtkLabel GtkWidget *filedesc; // GtkLabel
GtkWidget *compress; // GtkComboBox GtkWidget *compress; // GtkComboBox
GtkWidget *multi; // GtkCheckButton GtkWidget *multi; // GtkCheckButton
GtkWidget *okbutton; // GtkButton GtkWidget *okbutton; // GtkButton
GtkWidget *cancelbutton; // GtkButton GtkWidget *cancelbutton; // GtkButton
}; };
extern struct DeviceBoxData devicebox; extern struct DeviceBoxData devicebox;
extern void DeviceBoxDestroy(); extern void DeviceBoxDestroy();
// extern void DeviceBoxUnfocus(); // extern void DeviceBoxUnfocus();
extern void DeviceBoxRefocus(); extern void DeviceBoxRefocus();
extern void DeviceBoxDisplay(); extern void DeviceBoxDisplay();
#endif /* DEVICEBOX_H */ #endif /* DEVICEBOX_H */

View File

@ -1,134 +1,71 @@
/* interface.c /* interface.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <string.h> // strcmp() #include <string.h> // strcmp()
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit() #include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
#include <gtk/gtkwidget.h> // gtk_widget_show_all() #include <gtk/gtkwidget.h> // gtk_widget_show_all()
#include "logfile.h" #include "logfile.h"
#include "conf.h" #include "conf.h"
#include "aboutbox.h" #include "aboutbox.h"
#include "mainbox.h" #include "mainbox.h"
#include "devicebox.h" #include "devicebox.h"
#include "selectionbox.h" #include "selectionbox.h"
#include "progressbox.h" #include "progressbox.h"
#include "messagebox.h" #include "messagebox.h"
#include "conversionbox.h" #include "conversionbox.h"
#include "interface.h" #include "interface.h"
int main(int argc, char *argv[])
{
int main(int argc, char *argv[]) {
if (argc != 2) return(1); if (argc != 2) return(1);
gtk_init(NULL, NULL); gtk_init(NULL, NULL);
if (!strcmp(argv[1], "about"))
{
if(!strcmp(argv[1], "about")) {
AboutBoxDisplay(); AboutBoxDisplay();
return(0); return(0);
}
} else if (!strcmp(argv[1], "configure")) { else if (!strcmp(argv[1], "configure"))
{
OpenLog(); OpenLog();
InitConf(); InitConf();
LoadConf(); LoadConf();
MainBoxDisplay(); MainBoxDisplay();
DeviceBoxDisplay(); DeviceBoxDisplay();
ConversionBoxDisplay(); ConversionBoxDisplay();
ProgressBoxDisplay(); ProgressBoxDisplay();
MessageBoxDisplay(); MessageBoxDisplay();
SelectionBoxDisplay(); SelectionBoxDisplay();
gtk_widget_show_all(mainbox.window); gtk_widget_show_all(mainbox.window);
gtk_main(); gtk_main();
CloseLog(); CloseLog();
return(0); return(0);
} // ENDLONGIF- Which display would you like to see? } // ENDLONGIF- Which display would you like to see?
return(1); // No Displays chosen? Abort! return(1); // No Displays chosen? Abort!
} // END main() } // END main()

View File

@ -1,58 +1,26 @@
/* interface.h /* interface.h
* Copyright (C) 2002-2004 PCSX2 Team * Copyright (C) 2002-2004 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef INTERFACE_H #ifndef INTERFACE_H
#define INTERFACE_H #define INTERFACE_H
// Place holder... for now // Place holder... for now
#endif /* INTERFACE_H */ #endif /* INTERFACE_H */

View File

@ -1,180 +1,83 @@
/* logfile.c /* logfile.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <fcntl.h> // open #include <fcntl.h> // open
#include <stdio.h> // vsprintf() #include <stdio.h> // vsprintf()
#include <stdarg.h> // va_start(), va_end(), vsprintf() #include <stdarg.h> // va_start(), va_end(), vsprintf()
#include <sys/stat.h> // mkdir(), open() #include <sys/stat.h> // mkdir(), open()
#include <sys/types.h> // mkdir(), open() #include <sys/types.h> // mkdir(), open()
#include <unistd.h> // close(), write(), unlink() #include <unistd.h> // close(), write(), unlink()
#include "logfile.h" #include "logfile.h"
int logfile; int logfile;
char logfiletemp[2048]; char logfiletemp[2048];
void InitLog()
{
void InitLog() {
// Token comment line // Token comment line
#ifdef VERBOSE_LOGFILE #ifdef VERBOSE_LOGFILE
mkdir("./logs", 0755); mkdir("./logs", 0755);
unlink("./logs/CDVDlog.txt"); unlink("./logs/CDVDlog.txt");
#endif /* VERBOSE LOGFILE */ #endif /* VERBOSE LOGFILE */
} // END InitLog(); } // END InitLog();
int OpenLog()
{
int OpenLog() {
// Token comment line // Token comment line
#ifdef VERBOSE_LOGFILE #ifdef VERBOSE_LOGFILE
logfile = -1; logfile = -1;
logfile = open("./logs/CDVDlog.txt", O_WRONLY | O_CREAT | O_APPEND, 0755); logfile = open("./logs/CDVDlog.txt", O_WRONLY | O_CREAT | O_APPEND, 0755);
if (logfile == -1) return(-1); if (logfile == -1) return(-1);
#endif /* VERBOSE LOGFILE */ #endif /* VERBOSE LOGFILE */
return(0); return(0);
} // END OpenLog(); } // END OpenLog();
void CloseLog()
{
void CloseLog() {
// Token comment line // Token comment line
#ifdef VERBOSE_LOGFILE #ifdef VERBOSE_LOGFILE
if (logfile != -1)
if(logfile != -1) { {
close(logfile); close(logfile);
logfile = -1; logfile = -1;
} // ENDIF- Is the log file actually open? Close it. } // ENDIF- Is the log file actually open? Close it.
#endif /* VERBOSE LOGFILE */ #endif /* VERBOSE LOGFILE */
} // END CloseLog() } // END CloseLog()
void PrintLog(const char *fmt, ...)
{
void PrintLog(const char *fmt, ...) {
// Token comment line // Token comment line
#ifdef VERBOSE_LOGFILE #ifdef VERBOSE_LOGFILE
va_list list; va_list list;
int len; int len;
if (logfile == -1) return; // Log file not open. if (logfile == -1) return; // Log file not open.
va_start(list, fmt); va_start(list, fmt);
vsprintf(logfiletemp, fmt, list); vsprintf(logfiletemp, fmt, list);
va_end(list); va_end(list);
len = 0; len = 0;
while ((len < 2048) && (logfiletemp[len] != 0)) len++; while ((len < 2048) && (logfiletemp[len] != 0)) len++;
if ((len > 0) && (logfiletemp[len-1] == '\n')) len--; if ((len > 0) && (logfiletemp[len-1] == '\n')) len--;
if ((len > 0) && (logfiletemp[len-1] == '\r')) len--; if ((len > 0) && (logfiletemp[len-1] == '\r')) len--;
logfiletemp[len] = 0; // Slice off the last "\r\n"... logfiletemp[len] = 0; // Slice off the last "\r\n"...
write(logfile, logfiletemp, len); write(logfile, logfiletemp, len);
write(logfile, "\r\n", 2); // ... and write out your own. write(logfile, "\r\n", 2); // ... and write out your own.
#endif /* VERBOSE LOGFILE */ #endif /* VERBOSE LOGFILE */
} // END PrintLog() } // END PrintLog()

View File

@ -1,648 +1,317 @@
/* mainbox.c /* mainbox.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <string.h> // strcpy() #include <string.h> // strcpy()
#include <gtk/gtkbutton.h> // gtk_button_new_with_label() #include <gtk/gtkbutton.h> // gtk_button_new_with_label()
#include <gtk/gtkcheckbutton.h> // gtk_check_button_new_with_label() #include <gtk/gtkcheckbutton.h> // gtk_check_button_new_with_label()
#include <gtk/gtkcontainer.h> // gtk_container_add() #include <gtk/gtkcontainer.h> // gtk_container_add()
#include <gtk/gtkentry.h> // gtk_entry_new() #include <gtk/gtkentry.h> // gtk_entry_new()
#include <gtk/gtkfilesel.h> // gtk_file_selection_set_filename() #include <gtk/gtkfilesel.h> // gtk_file_selection_set_filename()
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new() #include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
#include <gtk/gtkhbox.h> // gtk_hbox_new() #include <gtk/gtkhbox.h> // gtk_hbox_new()
#include <gtk/gtklabel.h> // gtk_label_new() #include <gtk/gtklabel.h> // gtk_label_new()
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit() #include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
#include <gtk/gtktogglebutton.h> // gtk_toggle_button_set_active(), (_get_) #include <gtk/gtktogglebutton.h> // gtk_toggle_button_set_active(), (_get_)
#include <gtk/gtkvbox.h> // gtk_vbox_new() #include <gtk/gtkvbox.h> // gtk_vbox_new()
#include <gtk/gtkwindow.h> // gtk_window_new() #include <gtk/gtkwindow.h> // gtk_window_new()
#include "conf.h" #include "conf.h"
#include "isofile.h" #include "isofile.h"
#include "isocompress.h" // compressdesc[] #include "isocompress.h" // compressdesc[]
// #include "imagetype.h" // imagedata[].name // #include "imagetype.h" // imagedata[].name
#include "multifile.h" // multinames[] #include "multifile.h" // multinames[]
#include "tablerebuild.h" // IsoTableRebuild() #include "tablerebuild.h" // IsoTableRebuild()
#include "devicebox.h" #include "devicebox.h"
#include "conversionbox.h" #include "conversionbox.h"
#include "progressbox.h" #include "progressbox.h"
#include "messagebox.h" #include "messagebox.h"
#include "selectionbox.h" #include "selectionbox.h"
#include "mainbox.h" #include "mainbox.h"
struct MainBoxData mainbox; struct MainBoxData mainbox;
void MainBoxDestroy()
{
if (mainbox.window != NULL)
{
void MainBoxDestroy() {
if(mainbox.window != NULL) {
gtk_widget_destroy(mainbox.window); gtk_widget_destroy(mainbox.window);
mainbox.window = NULL; mainbox.window = NULL;
mainbox.file = NULL; mainbox.file = NULL;
mainbox.selectbutton = NULL; mainbox.selectbutton = NULL;
mainbox.desc = NULL; mainbox.desc = NULL;
mainbox.startcheck = NULL; mainbox.startcheck = NULL;
mainbox.restartcheck = NULL; mainbox.restartcheck = NULL;
mainbox.okbutton = NULL; mainbox.okbutton = NULL;
mainbox.devbutton = NULL; mainbox.devbutton = NULL;
mainbox.convbutton = NULL; mainbox.convbutton = NULL;
} // ENDIF- Do we have a Main Window still? } // ENDIF- Do we have a Main Window still?
} // END MainBoxDestroy() } // END MainBoxDestroy()
void MainBoxUnfocus()
{
void MainBoxUnfocus() {
gtk_widget_set_sensitive(mainbox.file, FALSE); gtk_widget_set_sensitive(mainbox.file, FALSE);
gtk_widget_set_sensitive(mainbox.selectbutton, FALSE); gtk_widget_set_sensitive(mainbox.selectbutton, FALSE);
gtk_widget_set_sensitive(mainbox.startcheck, FALSE); gtk_widget_set_sensitive(mainbox.startcheck, FALSE);
gtk_widget_set_sensitive(mainbox.restartcheck, FALSE); gtk_widget_set_sensitive(mainbox.restartcheck, FALSE);
gtk_widget_set_sensitive(mainbox.okbutton, FALSE); gtk_widget_set_sensitive(mainbox.okbutton, FALSE);
gtk_widget_set_sensitive(mainbox.devbutton, FALSE); gtk_widget_set_sensitive(mainbox.devbutton, FALSE);
gtk_widget_set_sensitive(mainbox.convbutton, FALSE); gtk_widget_set_sensitive(mainbox.convbutton, FALSE);
gtk_window_iconify(GTK_WINDOW(mainbox.window)); gtk_window_iconify(GTK_WINDOW(mainbox.window));
} // END MainBoxUnfocus() } // END MainBoxUnfocus()
gint MainBoxFileEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint MainBoxFileEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
int returnval; int returnval;
char templine[256]; char templine[256];
struct IsoFile *tempfile; struct IsoFile *tempfile;
returnval = IsIsoFile(gtk_entry_get_text(GTK_ENTRY(mainbox.file))); returnval = IsIsoFile(gtk_entry_get_text(GTK_ENTRY(mainbox.file)));
if (returnval == -1)
if(returnval == -1) { {
gtk_label_set_text(GTK_LABEL(mainbox.desc), "File Type: ---"); gtk_label_set_text(GTK_LABEL(mainbox.desc), "File Type: ---");
return(TRUE); return(TRUE);
} // ENDIF- Not a name of any sort? } // ENDIF- Not a name of any sort?
if (returnval == -2)
{
if(returnval == -2) {
gtk_label_set_text(GTK_LABEL(mainbox.desc), "File Type: Not a file"); gtk_label_set_text(GTK_LABEL(mainbox.desc), "File Type: Not a file");
return(TRUE); return(TRUE);
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
if (returnval == -3)
{
if(returnval == -3) {
gtk_label_set_text(GTK_LABEL(mainbox.desc), "File Type: Not a valid image file"); gtk_label_set_text(GTK_LABEL(mainbox.desc), "File Type: Not a valid image file");
return(TRUE); return(TRUE);
} // ENDIF- Not an Image file? } // ENDIF- Not an Image file?
if (returnval == -4)
{
if(returnval == -4) {
gtk_label_set_text(GTK_LABEL(mainbox.desc), "File Type: Missing Table File (will rebuild)"); gtk_label_set_text(GTK_LABEL(mainbox.desc), "File Type: Missing Table File (will rebuild)");
return(TRUE); return(TRUE);
} // ENDIF- Missing Compression seek table? } // ENDIF- Missing Compression seek table?
tempfile = IsoFileOpenForRead(gtk_entry_get_text(GTK_ENTRY(mainbox.file))); tempfile = IsoFileOpenForRead(gtk_entry_get_text(GTK_ENTRY(mainbox.file)));
sprintf(templine, "File Type: %s%s%s", sprintf(templine, "File Type: %s%s%s",
multinames[tempfile->multi], multinames[tempfile->multi],
tempfile->imagename, tempfile->imagename,
compressdesc[tempfile->compress]); compressdesc[tempfile->compress]);
gtk_label_set_text(GTK_LABEL(mainbox.desc), templine); gtk_label_set_text(GTK_LABEL(mainbox.desc), templine);
tempfile = IsoFileClose(tempfile); tempfile = IsoFileClose(tempfile);
return(TRUE); return(TRUE);
} // END MainBoxFileEvent() } // END MainBoxFileEvent()
void MainBoxRefocus()
{
void MainBoxRefocus() {
GdkEvent event; GdkEvent event;
MainBoxFileEvent(NULL, event, NULL); MainBoxFileEvent(NULL, event, NULL);
gtk_widget_set_sensitive(mainbox.file, TRUE); gtk_widget_set_sensitive(mainbox.file, TRUE);
gtk_widget_set_sensitive(mainbox.selectbutton, TRUE); gtk_widget_set_sensitive(mainbox.selectbutton, TRUE);
gtk_widget_set_sensitive(mainbox.startcheck, TRUE); gtk_widget_set_sensitive(mainbox.startcheck, TRUE);
gtk_widget_set_sensitive(mainbox.restartcheck, TRUE); gtk_widget_set_sensitive(mainbox.restartcheck, TRUE);
gtk_widget_set_sensitive(mainbox.okbutton, TRUE); gtk_widget_set_sensitive(mainbox.okbutton, TRUE);
gtk_widget_set_sensitive(mainbox.devbutton, TRUE); gtk_widget_set_sensitive(mainbox.devbutton, TRUE);
gtk_widget_set_sensitive(mainbox.convbutton, TRUE); gtk_widget_set_sensitive(mainbox.convbutton, TRUE);
gtk_window_set_focus(GTK_WINDOW(mainbox.window), mainbox.file); gtk_window_set_focus(GTK_WINDOW(mainbox.window), mainbox.file);
gtk_window_deiconify(GTK_WINDOW(mainbox.window)); gtk_window_deiconify(GTK_WINDOW(mainbox.window));
} // END MainBoxRefocus() } // END MainBoxRefocus()
gint MainBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint MainBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
mainbox.stop = 1; // Halt all long processess... mainbox.stop = 1; // Halt all long processess...
MessageBoxDestroy(); MessageBoxDestroy();
SelectionBoxDestroy(); SelectionBoxDestroy();
ProgressBoxDestroy(); ProgressBoxDestroy();
ConversionBoxDestroy(); ConversionBoxDestroy();
DeviceBoxDestroy(); DeviceBoxDestroy();
MainBoxDestroy(); MainBoxDestroy();
gtk_main_quit(); gtk_main_quit();
return(TRUE); return(TRUE);
} // END MainBoxCancelEvent() } // END MainBoxCancelEvent()
gint MainBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint MainBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
const char *tempisoname; const char *tempisoname;
MainBoxUnfocus(); MainBoxUnfocus();
tempisoname = gtk_entry_get_text(GTK_ENTRY(mainbox.file)); tempisoname = gtk_entry_get_text(GTK_ENTRY(mainbox.file));
if (*(tempisoname) != 0)
if(*(tempisoname) != 0) { {
if (IsIsoFile(tempisoname) == -4)
if(IsIsoFile(tempisoname) == -4) { {
IsoTableRebuild(tempisoname); IsoTableRebuild(tempisoname);
MainBoxRefocus(); MainBoxRefocus();
return(TRUE); return(TRUE);
} // ENDIF- Do we need to rebuild an image file's index before using it? } // ENDIF- Do we need to rebuild an image file's index before using it?
if (IsIsoFile(tempisoname) < 0)
{
if(IsIsoFile(tempisoname) < 0) {
tempisoname = NULL; tempisoname = NULL;
MainBoxRefocus(); MainBoxRefocus();
MessageBoxShow("Not a Valid Image File.", 1); MessageBoxShow("Not a Valid Image File.", 1);
return(TRUE); return(TRUE);
} // ENDIF- Not an ISO file? Message and Stop here. } // ENDIF- Not an ISO file? Message and Stop here.
} // ENDIF- Is there an ISO file to check out? } // ENDIF- Is there an ISO file to check out?
strcpy(conf.isoname, tempisoname); strcpy(conf.isoname, tempisoname);
tempisoname = NULL; tempisoname = NULL;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainbox.startcheck)) == FALSE)
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainbox.startcheck)) == FALSE) { {
conf.startconfigure = 0; // FALSE conf.startconfigure = 0; // FALSE
}
} else { else
{
conf.startconfigure = 1; // TRUE conf.startconfigure = 1; // TRUE
} // ENDIF- Was this check button turned off? } // ENDIF- Was this check button turned off?
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainbox.restartcheck)) == FALSE)
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainbox.restartcheck)) == FALSE) { {
conf.restartconfigure = 0; // FALSE conf.restartconfigure = 0; // FALSE
}
} else { else
{
conf.restartconfigure = 1; // TRUE conf.restartconfigure = 1; // TRUE
} // ENDIF- Was this check button turned off? } // ENDIF- Was this check button turned off?
SaveConf(); SaveConf();
MainBoxCancelEvent(widget, event, data); MainBoxCancelEvent(widget, event, data);
return(TRUE); return(TRUE);
} // END MainBoxOKEvent() } // END MainBoxOKEvent()
gint MainBoxBrowseEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint MainBoxBrowseEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
MainBoxUnfocus(); MainBoxUnfocus();
gtk_file_selection_set_filename(GTK_FILE_SELECTION(selectionbox.window), gtk_file_selection_set_filename(GTK_FILE_SELECTION(selectionbox.window),
gtk_entry_get_text(GTK_ENTRY(mainbox.file))); gtk_entry_get_text(GTK_ENTRY(mainbox.file)));
selectionbox.wherefrom = 1; // From the Main Window selectionbox.wherefrom = 1; // From the Main Window
SelectionBoxRefocus(); SelectionBoxRefocus();
return(TRUE); return(TRUE);
} // END MainBoxBrowseEvent() } // END MainBoxBrowseEvent()
gint MainBoxDeviceEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint MainBoxDeviceEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
MainBoxUnfocus(); MainBoxUnfocus();
gtk_entry_set_text(GTK_ENTRY(devicebox.file), gtk_entry_set_text(GTK_ENTRY(devicebox.file),
gtk_entry_get_text(GTK_ENTRY(mainbox.file))); gtk_entry_get_text(GTK_ENTRY(mainbox.file)));
gtk_window_set_focus(GTK_WINDOW(devicebox.window), devicebox.file); gtk_window_set_focus(GTK_WINDOW(devicebox.window), devicebox.file);
gtk_widget_show_all(devicebox.window); gtk_widget_show_all(devicebox.window);
return(TRUE); return(TRUE);
} // END MainBoxBrowseEvent() } // END MainBoxBrowseEvent()
gint MainBoxConversionEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint MainBoxConversionEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
MainBoxUnfocus(); MainBoxUnfocus();
gtk_entry_set_text(GTK_ENTRY(conversionbox.file), gtk_entry_set_text(GTK_ENTRY(conversionbox.file),
gtk_entry_get_text(GTK_ENTRY(mainbox.file))); gtk_entry_get_text(GTK_ENTRY(mainbox.file)));
gtk_window_set_focus(GTK_WINDOW(conversionbox.window), conversionbox.file); gtk_window_set_focus(GTK_WINDOW(conversionbox.window), conversionbox.file);
gtk_widget_show_all(conversionbox.window); gtk_widget_show_all(conversionbox.window);
return(TRUE); return(TRUE);
} // END MainBoxBrowseEvent() } // END MainBoxBrowseEvent()
void MainBoxDisplay()
{
void MainBoxDisplay() {
GtkWidget *item; GtkWidget *item;
GtkWidget *hbox1; GtkWidget *hbox1;
GtkWidget *vbox1; GtkWidget *vbox1;
mainbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); mainbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(mainbox.window), 5); gtk_container_set_border_width(GTK_CONTAINER(mainbox.window), 5);
gtk_window_set_title(GTK_WINDOW(mainbox.window), "CDVDisoEFP Configuration"); gtk_window_set_title(GTK_WINDOW(mainbox.window), "CDVDisoEFP Configuration");
gtk_window_set_position(GTK_WINDOW(mainbox.window), GTK_WIN_POS_CENTER); gtk_window_set_position(GTK_WINDOW(mainbox.window), GTK_WIN_POS_CENTER);
g_signal_connect(G_OBJECT(mainbox.window), "delete_event", g_signal_connect(G_OBJECT(mainbox.window), "delete_event",
G_CALLBACK(MainBoxCancelEvent), NULL); G_CALLBACK(MainBoxCancelEvent), NULL);
vbox1 = gtk_vbox_new(FALSE, 5); vbox1 = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(mainbox.window), vbox1); gtk_container_add(GTK_CONTAINER(mainbox.window), vbox1);
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5); gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
gtk_widget_show(vbox1); gtk_widget_show(vbox1);
hbox1 = gtk_hbox_new(FALSE, 10); hbox1 = gtk_hbox_new(FALSE, 10);
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
item = gtk_label_new("Iso File:"); item = gtk_label_new("Iso File:");
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item); gtk_widget_show(item);
item = NULL; item = NULL;
mainbox.file = gtk_entry_new(); mainbox.file = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.file, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), mainbox.file, TRUE, TRUE, 0);
gtk_widget_show(mainbox.file); gtk_widget_show(mainbox.file);
g_signal_connect(G_OBJECT(mainbox.file), "changed", g_signal_connect(G_OBJECT(mainbox.file), "changed",
G_CALLBACK(MainBoxFileEvent), NULL); G_CALLBACK(MainBoxFileEvent), NULL);
mainbox.selectbutton = gtk_button_new_with_label("Browse"); mainbox.selectbutton = gtk_button_new_with_label("Browse");
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.selectbutton, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), mainbox.selectbutton, FALSE, FALSE, 0);
gtk_widget_show(mainbox.selectbutton); gtk_widget_show(mainbox.selectbutton);
g_signal_connect(G_OBJECT(mainbox.selectbutton), "clicked", g_signal_connect(G_OBJECT(mainbox.selectbutton), "clicked",
G_CALLBACK(MainBoxBrowseEvent), NULL); G_CALLBACK(MainBoxBrowseEvent), NULL);
hbox1 = NULL; hbox1 = NULL;
mainbox.desc = gtk_label_new("File Type: ---"); mainbox.desc = gtk_label_new("File Type: ---");
gtk_box_pack_start(GTK_BOX(vbox1), mainbox.desc, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), mainbox.desc, FALSE, FALSE, 0);
gtk_widget_show(mainbox.desc); gtk_widget_show(mainbox.desc);
// hbox1 = gtk_hbox_new(FALSE, 10); // hbox1 = gtk_hbox_new(FALSE, 10);
// gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); // gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
// gtk_widget_show(hbox1); // gtk_widget_show(hbox1);
mainbox.startcheck = gtk_check_button_new_with_label("Show Configure screen when starting emulation"); mainbox.startcheck = gtk_check_button_new_with_label("Show Configure screen when starting emulation");
gtk_box_pack_start(GTK_BOX(vbox1), mainbox.startcheck, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), mainbox.startcheck, FALSE, FALSE, 0);
gtk_widget_show(mainbox.startcheck); gtk_widget_show(mainbox.startcheck);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainbox.startcheck), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainbox.startcheck), FALSE);
if (conf.startconfigure != 0)
if(conf.startconfigure != 0) { {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainbox.startcheck), TRUE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainbox.startcheck), TRUE);
} // ENDIF- Is this box supposed to be checked? } // ENDIF- Is this box supposed to be checked?
mainbox.restartcheck = gtk_check_button_new_with_label("Show Configure screen when restarting emulation"); mainbox.restartcheck = gtk_check_button_new_with_label("Show Configure screen when restarting emulation");
gtk_box_pack_start(GTK_BOX(vbox1), mainbox.restartcheck, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), mainbox.restartcheck, FALSE, FALSE, 0);
gtk_widget_show(mainbox.restartcheck); gtk_widget_show(mainbox.restartcheck);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainbox.restartcheck), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainbox.restartcheck), FALSE);
if (conf.restartconfigure != 0)
if(conf.restartconfigure != 0) { {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainbox.restartcheck), TRUE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainbox.restartcheck), TRUE);
} // ENDIF- Is this box supposed to be checked? } // ENDIF- Is this box supposed to be checked?
hbox1 = gtk_hbutton_box_new(); hbox1 = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
mainbox.okbutton = gtk_button_new_with_label("Ok"); mainbox.okbutton = gtk_button_new_with_label("Ok");
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.okbutton, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), mainbox.okbutton, TRUE, TRUE, 0);
gtk_widget_show(mainbox.okbutton); gtk_widget_show(mainbox.okbutton);
g_signal_connect(G_OBJECT(mainbox.okbutton), "clicked", g_signal_connect(G_OBJECT(mainbox.okbutton), "clicked",
G_CALLBACK(MainBoxOKEvent), NULL); G_CALLBACK(MainBoxOKEvent), NULL);
mainbox.devbutton = gtk_button_new_with_label("Get from Disc"); mainbox.devbutton = gtk_button_new_with_label("Get from Disc");
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.devbutton, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), mainbox.devbutton, TRUE, TRUE, 0);
gtk_widget_show(mainbox.devbutton); gtk_widget_show(mainbox.devbutton);
g_signal_connect(G_OBJECT(mainbox.devbutton), "clicked", g_signal_connect(G_OBJECT(mainbox.devbutton), "clicked",
G_CALLBACK(MainBoxDeviceEvent), NULL); G_CALLBACK(MainBoxDeviceEvent), NULL);
mainbox.convbutton = gtk_button_new_with_label("Convert"); mainbox.convbutton = gtk_button_new_with_label("Convert");
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.convbutton, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), mainbox.convbutton, TRUE, TRUE, 0);
gtk_widget_show(mainbox.convbutton); gtk_widget_show(mainbox.convbutton);
g_signal_connect(G_OBJECT(mainbox.convbutton), "clicked", g_signal_connect(G_OBJECT(mainbox.convbutton), "clicked",
G_CALLBACK(MainBoxConversionEvent), NULL); G_CALLBACK(MainBoxConversionEvent), NULL);
item = gtk_button_new_with_label("Cancel"); item = gtk_button_new_with_label("Cancel");
gtk_box_pack_start(GTK_BOX(hbox1), item, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), item, TRUE, TRUE, 0);
gtk_widget_show(item); gtk_widget_show(item);
g_signal_connect(G_OBJECT(item), "clicked", g_signal_connect(G_OBJECT(item), "clicked",
G_CALLBACK(MainBoxCancelEvent), NULL); G_CALLBACK(MainBoxCancelEvent), NULL);
item = NULL; item = NULL;
hbox1 = NULL; hbox1 = NULL;
vbox1 = NULL; vbox1 = NULL;
// We held off setting the name until now... so description would show. // We held off setting the name until now... so description would show.
gtk_entry_set_text(GTK_ENTRY(mainbox.file), conf.isoname); gtk_entry_set_text(GTK_ENTRY(mainbox.file), conf.isoname);
} // END MainBoxDisplay() } // END MainBoxDisplay()

View File

@ -26,7 +26,8 @@
#include <gtk/gtkwidget.h> #include <gtk/gtkwidget.h>
struct MainBoxData { struct MainBoxData
{
GtkWidget *window; // GtkWindow GtkWidget *window; // GtkWindow
GtkWidget *file; // GtkEntry GtkWidget *file; // GtkEntry
GtkWidget *selectbutton; // GtkButton GtkWidget *selectbutton; // GtkButton

View File

@ -1,226 +1,108 @@
/* messagebox.c /* messagebox.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <gtk/gtkbutton.h> // gtk_button_new_with_label() #include <gtk/gtkbutton.h> // gtk_button_new_with_label()
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new() #include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
#include <gtk/gtklabel.h> // gtk_label_new() #include <gtk/gtklabel.h> // gtk_label_new()
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit() #include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
#include <gtk/gtkvbox.h> // gtk_vbox_new() #include <gtk/gtkvbox.h> // gtk_vbox_new()
#include <gtk/gtkwindow.h> // gtk_window_new() #include <gtk/gtkwindow.h> // gtk_window_new()
#include "mainbox.h" #include "mainbox.h"
#include "devicebox.h" #include "devicebox.h"
#include "conversionbox.h" #include "conversionbox.h"
#include "messagebox.h" #include "messagebox.h"
struct MessageBoxData messagebox; struct MessageBoxData messagebox;
void MessageBoxDestroy()
{
if (messagebox.window != NULL)
{
void MessageBoxDestroy() {
if(messagebox.window != NULL) {
gtk_widget_destroy(messagebox.window); gtk_widget_destroy(messagebox.window);
messagebox.window = NULL; messagebox.window = NULL;
messagebox.desc = NULL; messagebox.desc = NULL;
} // ENDIF- Do we have a Main Window still? } // ENDIF- Do we have a Main Window still?
} // END MessageBoxDestroy() } // END MessageBoxDestroy()
void MessageBoxShow(char *message, int wherefrom)
{
void MessageBoxShow(char *message, int wherefrom) {
gtk_label_set_text(GTK_LABEL(messagebox.desc), message); gtk_label_set_text(GTK_LABEL(messagebox.desc), message);
messagebox.wherefrom = wherefrom; messagebox.wherefrom = wherefrom;
gtk_widget_show_all(messagebox.window); gtk_widget_show_all(messagebox.window);
gtk_window_deiconify(GTK_WINDOW(messagebox.window)); gtk_window_deiconify(GTK_WINDOW(messagebox.window));
} // END MessageBox() } // END MessageBox()
gint MessageBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint MessageBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
gtk_widget_hide(messagebox.window); gtk_widget_hide(messagebox.window);
switch (messagebox.wherefrom)
{
switch(messagebox.wherefrom) {
case 1: case 1:
MainBoxRefocus(); MainBoxRefocus();
break; break;
case 2: case 2:
DeviceBoxRefocus(); DeviceBoxRefocus();
break; break;
case 3: case 3:
ConversionBoxRefocus(); ConversionBoxRefocus();
break; break;
} // ENDSWITCH- Whose window do I get to re-focus when this is done? } // ENDSWITCH- Whose window do I get to re-focus when this is done?
return(TRUE); return(TRUE);
} // END MessageBoxCancelEvent() } // END MessageBoxCancelEvent()
void MessageBoxDisplay()
{
void MessageBoxDisplay() {
GtkWidget *item; GtkWidget *item;
GtkWidget *hbox1; GtkWidget *hbox1;
GtkWidget *vbox1; GtkWidget *vbox1;
messagebox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); messagebox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(messagebox.window), 5); gtk_container_set_border_width(GTK_CONTAINER(messagebox.window), 5);
gtk_window_set_title(GTK_WINDOW(messagebox.window), "CDVDisoEFP"); gtk_window_set_title(GTK_WINDOW(messagebox.window), "CDVDisoEFP");
gtk_window_set_position(GTK_WINDOW(messagebox.window), GTK_WIN_POS_CENTER); gtk_window_set_position(GTK_WINDOW(messagebox.window), GTK_WIN_POS_CENTER);
gtk_window_set_resizable(GTK_WINDOW(messagebox.window), FALSE); gtk_window_set_resizable(GTK_WINDOW(messagebox.window), FALSE);
g_signal_connect(G_OBJECT(messagebox.window), "delete_event", g_signal_connect(G_OBJECT(messagebox.window), "delete_event",
G_CALLBACK(MessageBoxCancelEvent), NULL); G_CALLBACK(MessageBoxCancelEvent), NULL);
vbox1 = gtk_vbox_new(FALSE, 5); vbox1 = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(messagebox.window), vbox1); gtk_container_add(GTK_CONTAINER(messagebox.window), vbox1);
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5); gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
gtk_widget_show(vbox1); gtk_widget_show(vbox1);
messagebox.desc = gtk_label_new("Hi There!\r\nHow are you doing?"); messagebox.desc = gtk_label_new("Hi There!\r\nHow are you doing?");
gtk_box_pack_start(GTK_BOX(vbox1), messagebox.desc, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), messagebox.desc, FALSE, FALSE, 0);
gtk_widget_show(messagebox.desc); gtk_widget_show(messagebox.desc);
hbox1 = gtk_hbutton_box_new(); hbox1 = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
item = gtk_button_new_with_label("Cancel"); item = gtk_button_new_with_label("Cancel");
gtk_box_pack_start(GTK_BOX(hbox1), item, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), item, TRUE, TRUE, 0);
GTK_WIDGET_SET_FLAGS(item, GTK_CAN_DEFAULT); GTK_WIDGET_SET_FLAGS(item, GTK_CAN_DEFAULT);
gtk_widget_show(item); gtk_widget_show(item);
g_signal_connect(G_OBJECT(item), "clicked", g_signal_connect(G_OBJECT(item), "clicked",
G_CALLBACK(MessageBoxCancelEvent), NULL); G_CALLBACK(MessageBoxCancelEvent), NULL);
item = NULL; item = NULL;
hbox1 = NULL; hbox1 = NULL;
vbox1 = NULL; vbox1 = NULL;
} // END MessageBoxDisplay() } // END MessageBoxDisplay()

View File

@ -26,7 +26,8 @@
#include <gtk/gtkwidget.h> #include <gtk/gtkwidget.h>
struct MessageBoxData { struct MessageBoxData
{
GtkWidget *window; // GtkWindow GtkWidget *window; // GtkWindow
GtkWidget *desc; // GtkLabel GtkWidget *desc; // GtkLabel

View File

@ -1,288 +1,134 @@
/* progressbox.c /* progressbox.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
#include <gtk/gtkbutton.h> // gtk_button_new_with_label() #include <gtk/gtkbutton.h> // gtk_button_new_with_label()
#include <gtk/gtkcontainer.h> // gtk_container_add() #include <gtk/gtkcontainer.h> // gtk_container_add()
#include <gtk/gtkfilesel.h> // gtk_file_selection_set_filename() #include <gtk/gtkfilesel.h> // gtk_file_selection_set_filename()
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new() #include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
#include <gtk/gtkhbox.h> // gtk_hbox_new() #include <gtk/gtkhbox.h> // gtk_hbox_new()
#include <gtk/gtklabel.h> // gtk_label_new() #include <gtk/gtklabel.h> // gtk_label_new()
#include <gtk/gtkmain.h> // gtk_main_iteration(), gtk_events_pending() #include <gtk/gtkmain.h> // gtk_main_iteration(), gtk_events_pending()
#include <gtk/gtkprogressbar.h> // gtk_progress_bar_new() #include <gtk/gtkprogressbar.h> // gtk_progress_bar_new()
#include <gtk/gtkvbox.h> // gtk_vbox_new() #include <gtk/gtkvbox.h> // gtk_vbox_new()
#include <gtk/gtkwindow.h> // gtk_window_new() #include <gtk/gtkwindow.h> // gtk_window_new()
#include "progressbox.h" #include "progressbox.h"
struct ProgressBoxData progressbox; struct ProgressBoxData progressbox;
char progressboxline[256]; char progressboxline[256];
void ProgressBoxDestroy()
{
if (progressbox.window != NULL)
{
void ProgressBoxDestroy() {
if(progressbox.window != NULL) {
gtk_widget_destroy(progressbox.window); gtk_widget_destroy(progressbox.window);
progressbox.window = NULL; progressbox.window = NULL;
progressbox.desc = NULL; progressbox.desc = NULL;
} // ENDIF- Do we have a Main Window still? } // ENDIF- Do we have a Main Window still?
} // END ProgressBoxDestroy() } // END ProgressBoxDestroy()
void ProgressBoxStart(char *description, off64_t maximum)
{
void ProgressBoxStart(char *description, off64_t maximum) {
gtk_label_set_text(GTK_LABEL(progressbox.desc), description); gtk_label_set_text(GTK_LABEL(progressbox.desc), description);
progressbox.max = maximum; progressbox.max = maximum;
progressbox.gmax = maximum; progressbox.gmax = maximum;
progressbox.lastpct = 100; progressbox.lastpct = 100;
progressbox.stop = 0; progressbox.stop = 0;
ProgressBoxTick(0); ProgressBoxTick(0);
gtk_widget_show_all(progressbox.window); gtk_widget_show_all(progressbox.window);
gtk_window_deiconify(GTK_WINDOW(progressbox.window)); gtk_window_deiconify(GTK_WINDOW(progressbox.window));
} // END ProgressBoxStart() } // END ProgressBoxStart()
void ProgressBoxTick(off64_t current)
{
void ProgressBoxTick(off64_t current) {
gdouble gcur; gdouble gcur;
off64_t thispct; off64_t thispct;
gcur = current; gcur = current;
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbox.bar), gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbox.bar),
gcur / progressbox.gmax); gcur / progressbox.gmax);
sprintf(progressboxline, "%llu of %llu", current, progressbox.max); sprintf(progressboxline, "%llu of %llu", current, progressbox.max);
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progressbox.bar), progressboxline); gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progressbox.bar), progressboxline);
if (progressbox.max >= 100)
{
if(progressbox.max >= 100) {
thispct = current / (progressbox.max / 100); thispct = current / (progressbox.max / 100);
if (thispct != progressbox.lastpct)
if(thispct != progressbox.lastpct) { {
sprintf(progressboxline, "%llu%% CDVDisoEFP Progress", thispct); sprintf(progressboxline, "%llu%% CDVDisoEFP Progress", thispct);
gtk_window_set_title(GTK_WINDOW(progressbox.window), progressboxline); gtk_window_set_title(GTK_WINDOW(progressbox.window), progressboxline);
progressbox.lastpct = thispct; progressbox.lastpct = thispct;
} // ENDIF- Change in percentage? (Avoiding title flicker) } // ENDIF- Change in percentage? (Avoiding title flicker)
} // ENDIF- Our maximum # over 100? (Avoiding divide-by-zero error) } // ENDIF- Our maximum # over 100? (Avoiding divide-by-zero error)
while (gtk_events_pending()) gtk_main_iteration(); // Give time for window to redraw. while (gtk_events_pending()) gtk_main_iteration(); // Give time for window to redraw.
} // END ProgressBoxTick() } // END ProgressBoxTick()
void ProgressBoxStop()
{
void ProgressBoxStop() {
gtk_widget_hide(progressbox.window); gtk_widget_hide(progressbox.window);
gtk_window_set_title(GTK_WINDOW(progressbox.window), "CDVDisoEFP Progress"); gtk_window_set_title(GTK_WINDOW(progressbox.window), "CDVDisoEFP Progress");
} // END ProgressBoxStop() } // END ProgressBoxStop()
gint ProgressBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint ProgressBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
progressbox.stop = 1; progressbox.stop = 1;
return(TRUE); return(TRUE);
} // END ProgressBoxCancelEvent() } // END ProgressBoxCancelEvent()
void ProgressBoxDisplay()
{
void ProgressBoxDisplay() {
GtkWidget *item; GtkWidget *item;
GtkWidget *hbox1; GtkWidget *hbox1;
GtkWidget *vbox1; GtkWidget *vbox1;
progressbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); progressbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(progressbox.window), 5); gtk_container_set_border_width(GTK_CONTAINER(progressbox.window), 5);
gtk_window_set_title(GTK_WINDOW(progressbox.window), "CDVDisoEFP Progress"); gtk_window_set_title(GTK_WINDOW(progressbox.window), "CDVDisoEFP Progress");
gtk_window_set_position(GTK_WINDOW(progressbox.window), GTK_WIN_POS_CENTER); gtk_window_set_position(GTK_WINDOW(progressbox.window), GTK_WIN_POS_CENTER);
gtk_window_set_resizable(GTK_WINDOW(progressbox.window), FALSE); gtk_window_set_resizable(GTK_WINDOW(progressbox.window), FALSE);
g_signal_connect(G_OBJECT(progressbox.window), "delete_event", g_signal_connect(G_OBJECT(progressbox.window), "delete_event",
G_CALLBACK(ProgressBoxCancelEvent), NULL); G_CALLBACK(ProgressBoxCancelEvent), NULL);
vbox1 = gtk_vbox_new(FALSE, 5); vbox1 = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(progressbox.window), vbox1); gtk_container_add(GTK_CONTAINER(progressbox.window), vbox1);
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5); gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
gtk_widget_show(vbox1); gtk_widget_show(vbox1);
progressbox.desc = gtk_label_new("Twiddling Thumbs"); progressbox.desc = gtk_label_new("Twiddling Thumbs");
gtk_box_pack_start(GTK_BOX(vbox1), progressbox.desc, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), progressbox.desc, FALSE, FALSE, 0);
gtk_widget_show(progressbox.desc); gtk_widget_show(progressbox.desc);
progressbox.bar = gtk_progress_bar_new(); progressbox.bar = gtk_progress_bar_new();
gtk_box_pack_start(GTK_BOX(vbox1), progressbox.bar, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), progressbox.bar, FALSE, FALSE, 0);
gtk_widget_show(progressbox.bar); gtk_widget_show(progressbox.bar);
hbox1 = gtk_hbutton_box_new(); hbox1 = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1); gtk_widget_show(hbox1);
item = gtk_button_new_with_label("Cancel"); item = gtk_button_new_with_label("Cancel");
gtk_box_pack_start(GTK_BOX(hbox1), item, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), item, TRUE, TRUE, 0);
GTK_WIDGET_SET_FLAGS(item, GTK_CAN_DEFAULT); GTK_WIDGET_SET_FLAGS(item, GTK_CAN_DEFAULT);
gtk_widget_show(item); gtk_widget_show(item);
g_signal_connect(G_OBJECT(item), "clicked", g_signal_connect(G_OBJECT(item), "clicked",
G_CALLBACK(ProgressBoxCancelEvent), NULL); G_CALLBACK(ProgressBoxCancelEvent), NULL);
item = NULL; item = NULL;
hbox1 = NULL; hbox1 = NULL;
vbox1 = NULL; vbox1 = NULL;
} // END ProgressBoxDisplay() } // END ProgressBoxDisplay()

View File

@ -30,7 +30,8 @@
extern const char *compressnames[]; extern const char *compressnames[];
struct ProgressBoxData { struct ProgressBoxData
{
GtkWidget *window; // GtkWindow GtkWidget *window; // GtkWindow
GtkWidget *desc; // GtkLabel - What are we showing progress on? GtkWidget *desc; // GtkLabel - What are we showing progress on?
GtkWidget *bar; // GtkProgressBar GtkWidget *bar; // GtkProgressBar

View File

@ -1,204 +1,99 @@
/* selectionbox.c /* selectionbox.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <glib-object.h> // g_signal_connect() #include <glib-object.h> // g_signal_connect()
#include <gtk/gtkentry.h> // gtk_entry_set_text() #include <gtk/gtkentry.h> // gtk_entry_set_text()
#include <gtk/gtkfilesel.h> // gtk_file_selection_new() #include <gtk/gtkfilesel.h> // gtk_file_selection_new()
#include "devicebox.h" #include "devicebox.h"
#include "conversionbox.h" #include "conversionbox.h"
#include "selectionbox.h" #include "selectionbox.h"
#include "mainbox.h" #include "mainbox.h"
struct SelectionBoxData selectionbox; struct SelectionBoxData selectionbox;
void SelectionBoxDestroy()
{
if (selectionbox.window != NULL)
{
void SelectionBoxDestroy() {
if(selectionbox.window != NULL) {
gtk_widget_destroy(selectionbox.window); gtk_widget_destroy(selectionbox.window);
selectionbox.window = NULL; selectionbox.window = NULL;
} // ENDIF- Do we have a Main Window still? } // ENDIF- Do we have a Main Window still?
} // END SelectionBoxDestroy() } // END SelectionBoxDestroy()
void SelectionBoxRefresh()
{
void SelectionBoxRefresh() {
} // END SelectionBoxRefresh() } // END SelectionBoxRefresh()
void SelectionBoxUnfocus()
{
void SelectionBoxUnfocus() {
gtk_widget_hide(selectionbox.window); gtk_widget_hide(selectionbox.window);
} // END SelectionBoxUnfocus() } // END SelectionBoxUnfocus()
void SelectionBoxRefocus()
{
void SelectionBoxRefocus() {
gtk_widget_show(selectionbox.window); gtk_widget_show(selectionbox.window);
} // END SelectionBoxRefocus() } // END SelectionBoxRefocus()
gint SelectionBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint SelectionBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
SelectionBoxUnfocus(); SelectionBoxUnfocus();
switch (selectionbox.wherefrom)
switch(selectionbox.wherefrom) { {
case 1: case 1:
gtk_entry_set_text(GTK_ENTRY(mainbox.file), gtk_entry_set_text(GTK_ENTRY(mainbox.file),
gtk_file_selection_get_filename(GTK_FILE_SELECTION(selectionbox.window))); gtk_file_selection_get_filename(GTK_FILE_SELECTION(selectionbox.window)));
MainBoxRefocus(); MainBoxRefocus();
break; break;
case 2: case 2:
gtk_entry_set_text(GTK_ENTRY(devicebox.file), gtk_entry_set_text(GTK_ENTRY(devicebox.file),
gtk_file_selection_get_filename(GTK_FILE_SELECTION(selectionbox.window))); gtk_file_selection_get_filename(GTK_FILE_SELECTION(selectionbox.window)));
DeviceBoxRefocus(); DeviceBoxRefocus();
break; break;
case 3: case 3:
gtk_entry_set_text(GTK_ENTRY(conversionbox.file), gtk_entry_set_text(GTK_ENTRY(conversionbox.file),
gtk_file_selection_get_filename(GTK_FILE_SELECTION(selectionbox.window))); gtk_file_selection_get_filename(GTK_FILE_SELECTION(selectionbox.window)));
ConversionBoxRefocus(); ConversionBoxRefocus();
break; break;
} // ENDSWITCH wherefrom- What Box called us? } // ENDSWITCH wherefrom- What Box called us?
return(TRUE); return(TRUE);
} // END SelectionBoxCancelEvent() } // END SelectionBoxCancelEvent()
gint SelectionBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
gint SelectionBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
// Validate listed file(?) // Validate listed file(?)
// Transfer file name to calling window? // Transfer file name to calling window?
SelectionBoxCancelEvent(widget, event, data); SelectionBoxCancelEvent(widget, event, data);
return(TRUE); return(TRUE);
} // END SelectionBoxOKEvent() } // END SelectionBoxOKEvent()
void SelectionBoxDisplay()
{
void SelectionBoxDisplay() {
selectionbox.window = gtk_file_selection_new("Select an ISO file"); selectionbox.window = gtk_file_selection_new("Select an ISO file");
g_signal_connect(G_OBJECT(selectionbox.window), "delete_event", g_signal_connect(G_OBJECT(selectionbox.window), "delete_event",
G_CALLBACK(SelectionBoxCancelEvent), NULL); G_CALLBACK(SelectionBoxCancelEvent), NULL);
g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(selectionbox.window)->ok_button), g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(selectionbox.window)->ok_button),
"clicked", G_CALLBACK(SelectionBoxOKEvent), NULL); "clicked", G_CALLBACK(SelectionBoxOKEvent), NULL);
g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(selectionbox.window)->cancel_button), g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(selectionbox.window)->cancel_button),
"clicked", G_CALLBACK(SelectionBoxCancelEvent), NULL); "clicked", G_CALLBACK(SelectionBoxCancelEvent), NULL);
selectionbox.wherefrom = 0; // Called by no one... yet. selectionbox.wherefrom = 0; // Called by no one... yet.
} // END SelectionBoxDisplay() } // END SelectionBoxDisplay()

View File

@ -26,7 +26,8 @@
#include <gtk/gtkwidget.h> #include <gtk/gtkwidget.h>
struct SelectionBoxData { struct SelectionBoxData
{
GtkWidget *window; // GtkWindow GtkWidget *window; // GtkWindow
int wherefrom; // Which box called you? int wherefrom; // Which box called you?

View File

@ -1,380 +1,190 @@
/* tablerebuild.c /* tablerebuild.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <stdlib.h> // malloc() #include <stdlib.h> // malloc()
// #include <gtk/gtkmain.h> // gtk_main_iteration() // #include <gtk/gtkmain.h> // gtk_main_iteration()
#include "mainbox.h" #include "mainbox.h"
#include "progressbox.h" #include "progressbox.h"
#include "isofile.h" #include "isofile.h"
#include "multifile.h" #include "multifile.h"
#include "isocompress.h" // CompressClose() #include "isocompress.h" // CompressClose()
#include "gzipv1.h" #include "gzipv1.h"
#include "gzipv2.h" #include "gzipv2.h"
#include "bzip2v2.h" #include "bzip2v2.h"
#include "bzip2v3.h" #include "bzip2v3.h"
#include "actualfile.h" // ACTUALHANDLENULL #include "actualfile.h" // ACTUALHANDLENULL
void IsoTableRebuild(const char *filename)
{
void IsoTableRebuild(const char *filename) {
struct IsoFile *datafile; struct IsoFile *datafile;
struct IsoFile *tablefile; struct IsoFile *tablefile;
int retval; int retval;
char tempblock[65536]; char tempblock[65536];
int stop; int stop;
struct TableData table; struct TableData table;
datafile = IsoFileOpenForRead(filename); datafile = IsoFileOpenForRead(filename);
// Note: This is the start of the "Multifile" process. It's commented // Note: This is the start of the "Multifile" process. It's commented
// out so at least we can rebuild 1 part of a multifile at a time. // out so at least we can rebuild 1 part of a multifile at a time.
// IsoNameStripExt(datafile); // IsoNameStripExt(datafile);
// IsoNameStripMulti(datafile); // IsoNameStripMulti(datafile);
// Prep tablefile to hold ONLY a table (no data) // Prep tablefile to hold ONLY a table (no data)
tablefile = (struct IsoFile *) malloc(sizeof(struct IsoFile)); tablefile = (struct IsoFile *) malloc(sizeof(struct IsoFile));
if (tablefile == NULL)
if(tablefile == NULL) { {
datafile = IsoFileClose(datafile); datafile = IsoFileClose(datafile);
return; return;
} // ENDIF- Failed to allocate? Abort. } // ENDIF- Failed to allocate? Abort.
tablefile->sectorpos = 0; tablefile->sectorpos = 0;
tablefile->openforread = 0; tablefile->openforread = 0;
tablefile->filebytepos = 0; tablefile->filebytepos = 0;
tablefile->filebytesize = 0; tablefile->filebytesize = 0;
tablefile->filesectorpos = 0; tablefile->filesectorpos = 0;
tablefile->filesectorsize = 0; tablefile->filesectorsize = 0;
tablefile->handle = ACTUALHANDLENULL; tablefile->handle = ACTUALHANDLENULL;
tablefile->namepos = 0; tablefile->namepos = 0;
while ((tablefile->namepos < 255) && while ((tablefile->namepos < 255) &&
(*(filename + tablefile->namepos) != 0))
(*(filename + tablefile->namepos) != 0)) { {
tablefile->name[tablefile->namepos] = *(filename + tablefile->namepos); tablefile->name[tablefile->namepos] = *(filename + tablefile->namepos);
tablefile->namepos++; tablefile->namepos++;
} // ENDWHILE- Copying file name into tablefile } // ENDWHILE- Copying file name into tablefile
tablefile->name[tablefile->namepos] = 0; // And 0-terminate. tablefile->name[tablefile->namepos] = 0; // And 0-terminate.
tablefile->imageheader = datafile->imageheader; tablefile->imageheader = datafile->imageheader;
tablefile->blocksize = datafile->blocksize; tablefile->blocksize = datafile->blocksize;
tablefile->blockoffset = datafile->blockoffset; tablefile->blockoffset = datafile->blockoffset;
tablefile->cdvdtype = 0; // Not important right now. tablefile->cdvdtype = 0; // Not important right now.
tablefile->compress = datafile->compress; tablefile->compress = datafile->compress;
tablefile->compresspos = datafile->compresspos; tablefile->compresspos = datafile->compresspos;
tablefile->numsectors = datafile->numsectors; tablefile->numsectors = datafile->numsectors;
tablefile->tabledata = NULL; tablefile->tabledata = NULL;
switch (tablefile->compress)
{
switch(tablefile->compress) {
case 1: case 1:
retval = GZipV1OpenTableForWrite(tablefile); retval = GZipV1OpenTableForWrite(tablefile);
break; break;
case 2: case 2:
retval = -1; retval = -1;
break; break;
case 3: case 3:
retval = GZipV2OpenTableForWrite(tablefile); retval = GZipV2OpenTableForWrite(tablefile);
break; break;
case 4: case 4:
retval = BZip2V2OpenTableForWrite(tablefile); retval = BZip2V2OpenTableForWrite(tablefile);
break; break;
case 5: case 5:
retval = BZip2V3OpenTableForWrite(tablefile); retval = BZip2V3OpenTableForWrite(tablefile);
break; break;
default: default:
retval = -1; retval = -1;
break; break;
} // ENDSWITCH compress- Which table are we writing out? } // ENDSWITCH compress- Which table are we writing out?
if (retval < 0)
if(retval < 0) { {
datafile = IsoFileClose(datafile); datafile = IsoFileClose(datafile);
return; return;
} // ENDIF- Failed to open table file? Abort } // ENDIF- Failed to open table file? Abort
sprintf(tempblock, "Rebuilding table for %s", datafile->name); sprintf(tempblock, "Rebuilding table for %s", datafile->name);
ProgressBoxStart(tempblock, datafile->filebytesize); ProgressBoxStart(tempblock, datafile->filebytesize);
stop = 0; stop = 0;
mainbox.stop = 0; mainbox.stop = 0;
progressbox.stop = 0; progressbox.stop = 0;
while ((stop == 0) && (datafile->filebytepos < datafile->filebytesize))
while((stop == 0) && (datafile->filebytepos < datafile->filebytesize)) { {
switch (datafile->compress)
switch(datafile->compress) { {
case 1: case 1:
retval = GZipV1Read(datafile, 0, tempblock); retval = GZipV1Read(datafile, 0, tempblock);
break; break;
case 2: case 2:
retval = -1; retval = -1;
break; break;
case 3: case 3:
retval = GZipV2Read(datafile, 0, tempblock); retval = GZipV2Read(datafile, 0, tempblock);
break; break;
case 4: case 4:
retval = BZip2V2Read(datafile, 0, tempblock); retval = BZip2V2Read(datafile, 0, tempblock);
break; break;
case 5: case 5:
retval = BZip2V3Read(datafile, 0, tempblock); retval = BZip2V3Read(datafile, 0, tempblock);
break; break;
default: default:
retval = -1; retval = -1;
break; break;
} // ENDSWITCH compress- Scanning for the next complete compressed block } // ENDSWITCH compress- Scanning for the next complete compressed block
if (retval <= 0)
{
if(retval <= 0) {
#ifdef FUNCTION_WARNING_TABLEREBUILD #ifdef FUNCTION_WARNING_TABLEREBUILD
PrintLog("CDVDiso rebuild: failed to decompress - data corrupt"); PrintLog("CDVDiso rebuild: failed to decompress - data corrupt");
#endif /* FUNCTION_WARNING_TABLEREBUILD */ #endif /* FUNCTION_WARNING_TABLEREBUILD */
stop = 1; stop = 1;
}
} else { else
{
table.offset = datafile->filebytepos - retval; table.offset = datafile->filebytepos - retval;
table.size = retval; table.size = retval;
switch (tablefile->compress)
switch(tablefile->compress) { {
case 1: case 1:
retval = GZipV1WriteTable(tablefile, table); retval = GZipV1WriteTable(tablefile, table);
break; break;
case 2: case 2:
retval = -1; retval = -1;
break; break;
case 3: case 3:
retval = GZipV2WriteTable(tablefile, table); retval = GZipV2WriteTable(tablefile, table);
break; break;
case 4: case 4:
retval = BZip2V2WriteTable(tablefile, table); retval = BZip2V2WriteTable(tablefile, table);
break; break;
case 5: case 5:
retval = BZip2V3WriteTable(tablefile, table); retval = BZip2V3WriteTable(tablefile, table);
break; break;
default: default:
retval = -1; retval = -1;
break; break;
} // ENDSWITCH compress- Writing out the relavent table facts } // ENDSWITCH compress- Writing out the relavent table facts
if (retval < 0) stop = 1; if (retval < 0) stop = 1;
} // ENDIF- Do we have a valid record to write an entry for? } // ENDIF- Do we have a valid record to write an entry for?
ProgressBoxTick(datafile->filebytepos); ProgressBoxTick(datafile->filebytepos);
// while(gtk_events_pending()) gtk_main_iteration(); // while(gtk_events_pending()) gtk_main_iteration();
if (mainbox.stop != 0) stop = 2; if (mainbox.stop != 0) stop = 2;
if (progressbox.stop != 0) stop = 2; if (progressbox.stop != 0) stop = 2;
} // ENDWHILE- Read in the data file and writing a table, 1 block at a time } // ENDWHILE- Read in the data file and writing a table, 1 block at a time
ProgressBoxStop(); ProgressBoxStop();
CompressClose(tablefile); // Guarentee the table is flushed and closed. CompressClose(tablefile); // Guarentee the table is flushed and closed.
if (stop != 0)
if(stop != 0) { {
ActualFileDelete(tablefile->tablename); ActualFileDelete(tablefile->tablename);
} // ENDIF- Aborted or trouble? Delete the table file } // ENDIF- Aborted or trouble? Delete the table file
tablefile = IsoFileClose(tablefile); tablefile = IsoFileClose(tablefile);
datafile = IsoFileClose(datafile); datafile = IsoFileClose(datafile);
return; return;
} // END IsoTableRebuild() } // END IsoTableRebuild()

View File

@ -23,23 +23,17 @@
* reserved keys: * reserved keys:
F1 to F10 are reserved for the emulator F1 to F10 are reserved for the emulator
* plugins should NOT change the current * plugins should NOT change the current
working directory. working directory.
(on win32, add flag OFN_NOCHANGEDIR for (on win32, add flag OFN_NOCHANGEDIR for
GetOpenFileName) GetOpenFileName)
*/ */
#include "PS2Etypes.h" #include "PS2Etypes.h"
#ifdef __LINUX__ #ifdef __LINUX__
#define CALLBACK #define CALLBACK
#else #else
#include <windows.h> #include <windows.h>
#endif #endif
/* common defines */ /* common defines */
#ifndef C_ASSERT #ifndef C_ASSERT
#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
@ -71,42 +65,37 @@
#define PS2E_FW_VERSION 0x0002 #define PS2E_FW_VERSION 0x0002
#define PS2E_SIO_VERSION 0x0001 #define PS2E_SIO_VERSION 0x0001
#ifdef COMMONdefs #ifdef COMMONdefs
u32 CALLBACK PS2EgetLibType(void); u32 CALLBACK PS2EgetLibType(void);
u32 CALLBACK PS2EgetLibVersion2(u32 type); u32 CALLBACK PS2EgetLibVersion2(u32 type);
char* CALLBACK PS2EgetLibName(void); char* CALLBACK PS2EgetLibName(void);
#endif #endif
// key values: // key values:
/* key values must be OS dependant: /* key values must be OS dependant:
win32: the VK_XXX will be used (WinUser) win32: the VK_XXX will be used (WinUser)
linux: the XK_XXX will be used (XFree86) linux: the XK_XXX will be used (XFree86)
*/ */
// event values: // event values:
#define KEYPRESS 1 #define KEYPRESS 1
#define KEYRELEASE 2 #define KEYRELEASE 2
typedef struct
typedef struct { {
u32 key; u32 key;
u32 event; u32 event;
} keyEvent; } keyEvent;
// for 64bit compilers // for 64bit compilers
typedef char __keyEvent_Size__[(sizeof(keyEvent) == 8)?1:-1]; typedef char __keyEvent_Size__[(sizeof(keyEvent) == 8)?1:-1];
// plugin types // plugin types
#define SIO_TYPE_PAD 0x00000001 #define SIO_TYPE_PAD 0x00000001
#define SIO_TYPE_MTAP 0x00000004 #define SIO_TYPE_MTAP 0x00000004
#define SIO_TYPE_RM 0x00000040 #define SIO_TYPE_RM 0x00000040
#define SIO_TYPE_MC 0x00000100 #define SIO_TYPE_MC 0x00000100
typedef int (CALLBACK * SIOchangeSlotCB)(int slot); typedef int (CALLBACK * SIOchangeSlotCB)(int slot);
typedef struct
typedef struct { {
u8 ctrl:4; // control and mode bits u8 ctrl:
u8 mode:4; // control and mode bits 4; // control and mode bits
u8 mode:
4; // control and mode bits
u8 trackNum; // current track number (1 to 99) u8 trackNum; // current track number (1 to 99)
u8 trackIndex; // current index within track (0 to 99) u8 trackIndex; // current index within track (0 to 99)
u8 trackM; // current minute location on the disc (BCD encoded) u8 trackM; // current minute location on the disc (BCD encoded)
@ -117,17 +106,16 @@ typedef struct {
u8 discS; // current sector offset from first track (BCD encoded) u8 discS; // current sector offset from first track (BCD encoded)
u8 discF; // current frame offset from first track (BCD encoded) u8 discF; // current frame offset from first track (BCD encoded)
} cdvdSubQ; } cdvdSubQ;
typedef struct // NOT bcd coded
typedef struct { // NOT bcd coded {
u32 lsn; u32 lsn;
u8 type; u8 type;
} cdvdTD; } cdvdTD;
typedef struct
typedef struct { {
u8 strack; //number of the first track (usually 1) u8 strack; //number of the first track (usually 1)
u8 etrack; //number of the last track u8 etrack; //number of the last track
} cdvdTN; } cdvdTN;
// CDVDreadTrack mode values: // CDVDreadTrack mode values:
#define CDVD_MODE_2352 0 // full 2352 bytes #define CDVD_MODE_2352 0 // full 2352 bytes
#define CDVD_MODE_2340 1 // skip sync (12) bytes #define CDVD_MODE_2340 1 // skip sync (12) bytes
@ -159,43 +147,36 @@ typedef struct {
#define CDVD_AUDIO_TRACK 0x01 #define CDVD_AUDIO_TRACK 0x01
#define CDVD_MODE1_TRACK 0x41 #define CDVD_MODE1_TRACK 0x41
#define CDVD_MODE2_TRACK 0x61 #define CDVD_MODE2_TRACK 0x61
#define CDVD_AUDIO_MASK 0x00 #define CDVD_AUDIO_MASK 0x00
#define CDVD_DATA_MASK 0x40 #define CDVD_DATA_MASK 0x40
// CDROM_DATA_TRACK 0x04 //do not enable this! (from linux kernel) // CDROM_DATA_TRACK 0x04 //do not enable this! (from linux kernel)
typedef void (*DEV9callback)(int cycles); typedef void (*DEV9callback)(int cycles);
typedef int (*DEV9handler)(void); typedef int (*DEV9handler)(void);
typedef void (*USBcallback)(int cycles); typedef void (*USBcallback)(int cycles);
typedef int (*USBhandler)(void); typedef int (*USBhandler)(void);
// freeze modes: // freeze modes:
#define FREEZE_LOAD 0 #define FREEZE_LOAD 0
#define FREEZE_SAVE 1 #define FREEZE_SAVE 1
#define FREEZE_SIZE 2 #define FREEZE_SIZE 2
typedef struct
typedef struct { {
char name[8]; char name[8];
void *common; void *common;
} GSdriverInfo; } GSdriverInfo;
#ifdef _WIN32 #ifdef _WIN32
typedef struct { // unsupported values must be set to zero typedef struct // unsupported values must be set to zero
{
HWND hWnd; HWND hWnd;
HMENU hMenu; HMENU hMenu;
HWND hStatusWnd; HWND hStatusWnd;
} winInfo; } winInfo;
#endif #endif
/* GS plugin API */ /* GS plugin API */
// if this file is included with this define // if this file is included with this define
// the next api will not be skipped by the compiler // the next api will not be skipped by the compiler
#ifdef GSdefs #ifdef GSdefs
// basic funcs // basic funcs
s32 CALLBACK GSinit(); s32 CALLBACK GSinit();
s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread); s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread);
void CALLBACK GSclose(); void CALLBACK GSclose();
@ -207,9 +188,7 @@ void CALLBACK GSgifTransfer3(u32 *pMem, u32 size);
void CALLBACK GSgifSoftReset(u32 mask); void CALLBACK GSgifSoftReset(u32 mask);
void CALLBACK GSreadFIFO(off64_t *mem); void CALLBACK GSreadFIFO(off64_t *mem);
void CALLBACK GSreadFIFO2(off64_t *mem, int qwc); void CALLBACK GSreadFIFO2(off64_t *mem, int qwc);
// extended funcs // extended funcs
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin // GSkeyEvent gets called when there is a keyEvent from the PAD plugin
void CALLBACK GSkeyEvent(keyEvent *ev); void CALLBACK GSkeyEvent(keyEvent *ev);
void CALLBACK GSchangeSaveState(int, const char* filename); void CALLBACK GSchangeSaveState(int, const char* filename);
@ -219,10 +198,8 @@ void CALLBACK GSirqCallback(void (*callback)());
void CALLBACK GSprintf(int timeout, char *fmt, ...); void CALLBACK GSprintf(int timeout, char *fmt, ...);
void CALLBACK GSsetBaseMem(void*); void CALLBACK GSsetBaseMem(void*);
void CALLBACK GSsetGameCRC(int); void CALLBACK GSsetGameCRC(int);
// controls frame skipping in the GS, if this routine isn't present, frame skipping won't be done // controls frame skipping in the GS, if this routine isn't present, frame skipping won't be done
void CALLBACK GSsetFrameSkip(int frameskip); void CALLBACK GSsetFrameSkip(int frameskip);
void CALLBACK GSreset(); void CALLBACK GSreset();
void CALLBACK GSwriteCSR(u32 value); void CALLBACK GSwriteCSR(u32 value);
void CALLBACK GSgetDriverInfo(GSdriverInfo *info); void CALLBACK GSgetDriverInfo(GSdriverInfo *info);
@ -233,17 +210,12 @@ s32 CALLBACK GSfreeze(int mode, freezeData *data);
void CALLBACK GSconfigure(); void CALLBACK GSconfigure();
void CALLBACK GSabout(); void CALLBACK GSabout();
s32 CALLBACK GStest(); s32 CALLBACK GStest();
#endif #endif
/* PAD plugin API -=[ OBSOLETE ]=- */ /* PAD plugin API -=[ OBSOLETE ]=- */
// if this file is included with this define // if this file is included with this define
// the next api will not be skipped by the compiler // the next api will not be skipped by the compiler
#ifdef PADdefs #ifdef PADdefs
// basic funcs // basic funcs
s32 CALLBACK PADinit(u32 flags); s32 CALLBACK PADinit(u32 flags);
s32 CALLBACK PADopen(void *pDsp); s32 CALLBACK PADopen(void *pDsp);
void CALLBACK PADclose(); void CALLBACK PADclose();
@ -263,17 +235,12 @@ void CALLBACK PADgsDriverInfo(GSdriverInfo *info);
void CALLBACK PADconfigure(); void CALLBACK PADconfigure();
void CALLBACK PADabout(); void CALLBACK PADabout();
s32 CALLBACK PADtest(); s32 CALLBACK PADtest();
#endif #endif
/* SIO plugin API */ /* SIO plugin API */
// if this file is included with this define // if this file is included with this define
// the next api will not be skipped by the compiler // the next api will not be skipped by the compiler
#ifdef SIOdefs #ifdef SIOdefs
// basic funcs // basic funcs
s32 CALLBACK SIOinit(u32 port, u32 slot, SIOchangeSlotCB f); s32 CALLBACK SIOinit(u32 port, u32 slot, SIOchangeSlotCB f);
s32 CALLBACK SIOopen(void *pDsp); s32 CALLBACK SIOopen(void *pDsp);
void CALLBACK SIOclose(); void CALLBACK SIOclose();
@ -282,23 +249,16 @@ u8 CALLBACK SIOstartPoll(u8 value);
u8 CALLBACK SIOpoll(u8 value); u8 CALLBACK SIOpoll(u8 value);
// returns: SIO_TYPE_{PAD,MTAP,RM,MC} // returns: SIO_TYPE_{PAD,MTAP,RM,MC}
u32 CALLBACK SIOquery(); u32 CALLBACK SIOquery();
// extended funcs // extended funcs
void CALLBACK SIOconfigure(); void CALLBACK SIOconfigure();
void CALLBACK SIOabout(); void CALLBACK SIOabout();
s32 CALLBACK SIOtest(); s32 CALLBACK SIOtest();
#endif #endif
/* SPU2 plugin API */ /* SPU2 plugin API */
// if this file is included with this define // if this file is included with this define
// the next api will not be skipped by the compiler // the next api will not be skipped by the compiler
#ifdef SPU2defs #ifdef SPU2defs
// basic funcs // basic funcs
s32 CALLBACK SPU2init(); s32 CALLBACK SPU2init();
s32 CALLBACK SPU2open(void *pDsp); s32 CALLBACK SPU2open(void *pDsp);
void CALLBACK SPU2close(); void CALLBACK SPU2close();
@ -315,29 +275,22 @@ u32 CALLBACK SPU2ReadMemAddr(int core);
void CALLBACK SPU2WriteMemAddr(int core, u32 value); void CALLBACK SPU2WriteMemAddr(int core, u32 value);
void CALLBACK SPU2irqCallback(void (*SPU2callback)(), void (*DMA4callback)(), void (*DMA7callback)()); void CALLBACK SPU2irqCallback(void (*SPU2callback)(), void (*DMA4callback)(), void (*DMA7callback)());
// extended funcs // extended funcs
void CALLBACK SPU2async(u32 cycles); void CALLBACK SPU2async(u32 cycles);
s32 CALLBACK SPU2freeze(int mode, freezeData *data); s32 CALLBACK SPU2freeze(int mode, freezeData *data);
void CALLBACK SPU2configure(); void CALLBACK SPU2configure();
void CALLBACK SPU2about(); void CALLBACK SPU2about();
s32 CALLBACK SPU2test(); s32 CALLBACK SPU2test();
#endif #endif
/* CDVD plugin API */ /* CDVD plugin API */
// if this file is included with this define // if this file is included with this define
// the next api will not be skipped by the compiler // the next api will not be skipped by the compiler
#ifdef CDVDdefs #ifdef CDVDdefs
// basic funcs // basic funcs
s32 CALLBACK CDVDinit(); s32 CALLBACK CDVDinit();
s32 CALLBACK CDVDopen(const char* pTitleFilename); s32 CALLBACK CDVDopen(const char* pTitleFilename);
void CALLBACK CDVDclose(); void CALLBACK CDVDclose();
void CALLBACK CDVDshutdown(); void CALLBACK CDVDshutdown();
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode); s32 CALLBACK CDVDreadTrack(u32 lsn, int mode);
// return can be NULL (for async modes) // return can be NULL (for async modes)
u8* CALLBACK CDVDgetBuffer(); u8* CALLBACK CDVDgetBuffer();
@ -349,9 +302,7 @@ s32 CALLBACK CDVDgetDiskType(); //CDVD_TYPE_xxxx
s32 CALLBACK CDVDgetTrayStatus(); //CDVD_TRAY_xxxx s32 CALLBACK CDVDgetTrayStatus(); //CDVD_TRAY_xxxx
s32 CALLBACK CDVDctrlTrayOpen(); //open disc tray s32 CALLBACK CDVDctrlTrayOpen(); //open disc tray
s32 CALLBACK CDVDctrlTrayClose(); //close disc tray s32 CALLBACK CDVDctrlTrayClose(); //close disc tray
// extended funcs // extended funcs
void CALLBACK CDVDconfigure(); void CALLBACK CDVDconfigure();
void CALLBACK CDVDabout(); void CALLBACK CDVDabout();
s32 CALLBACK CDVDtest(); s32 CALLBACK CDVDtest();
@ -385,9 +336,7 @@ void CALLBACK DEV9writeDMA8Mem(u32 *pMem, int size);
// if callback returns 1 the irq is triggered, else not // if callback returns 1 the irq is triggered, else not
void CALLBACK DEV9irqCallback(DEV9callback callback); void CALLBACK DEV9irqCallback(DEV9callback callback);
DEV9handler CALLBACK DEV9irqHandler(void); DEV9handler CALLBACK DEV9irqHandler(void);
// extended funcs // extended funcs
s32 CALLBACK DEV9freeze(int mode, freezeData *data); s32 CALLBACK DEV9freeze(int mode, freezeData *data);
void CALLBACK DEV9configure(); void CALLBACK DEV9configure();
void CALLBACK DEV9about(); void CALLBACK DEV9about();
@ -425,16 +374,12 @@ s32 CALLBACK USBfreeze(int mode, freezeData *data);
void CALLBACK USBconfigure(); void CALLBACK USBconfigure();
void CALLBACK USBabout(); void CALLBACK USBabout();
s32 CALLBACK USBtest(); s32 CALLBACK USBtest();
#endif #endif
/* FW plugin API */ /* FW plugin API */
// if this file is included with this define // if this file is included with this define
// the next api will not be skipped by the compiler // the next api will not be skipped by the compiler
#ifdef FWdefs #ifdef FWdefs
// basic funcs // basic funcs
// NOTE: The read/write functions CANNOT use XMM/MMX regs // NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones // If you want to use them, need to save and restore current ones
s32 CALLBACK FWinit(); s32 CALLBACK FWinit();
@ -444,22 +389,17 @@ void CALLBACK FWshutdown();
u32 CALLBACK FWread32(u32 addr); u32 CALLBACK FWread32(u32 addr);
void CALLBACK FWwrite32(u32 addr, u32 value); void CALLBACK FWwrite32(u32 addr, u32 value);
void CALLBACK FWirqCallback(void (*callback)()); void CALLBACK FWirqCallback(void (*callback)());
// extended funcs // extended funcs
s32 CALLBACK FWfreeze(int mode, freezeData *data); s32 CALLBACK FWfreeze(int mode, freezeData *data);
void CALLBACK FWconfigure(); void CALLBACK FWconfigure();
void CALLBACK FWabout(); void CALLBACK FWabout();
s32 CALLBACK FWtest(); s32 CALLBACK FWtest();
#endif #endif
// might be useful for emulators // might be useful for emulators
#ifdef PLUGINtypedefs #ifdef PLUGINtypedefs
typedef u32(CALLBACK* _PS2EgetLibType)(void); typedef u32(CALLBACK* _PS2EgetLibType)(void);
typedef u32(CALLBACK* _PS2EgetLibVersion2)(u32 type); typedef u32(CALLBACK* _PS2EgetLibVersion2)(u32 type);
typedef char*(CALLBACK* _PS2EgetLibName)(void); typedef char*(CALLBACK* _PS2EgetLibName)(void);
// GS // GS
// NOTE: GSreadFIFOX/GSwriteCSR functions CANNOT use XMM/MMX regs // NOTE: GSreadFIFOX/GSwriteCSR functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones // If you want to use them, need to save and restore current ones
@ -474,7 +414,6 @@ typedef void (CALLBACK* _GSgifTransfer3)(u32 *pMem, u32 size);
typedef void (CALLBACK* _GSgifSoftReset)(u32 mask); typedef void (CALLBACK* _GSgifSoftReset)(u32 mask);
typedef void (CALLBACK* _GSreadFIFO)(off64_t *pMem); typedef void (CALLBACK* _GSreadFIFO)(off64_t *pMem);
typedef void (CALLBACK* _GSreadFIFO2)(off64_t *pMem, int qwc); typedef void (CALLBACK* _GSreadFIFO2)(off64_t *pMem, int qwc);
typedef void (CALLBACK* _GSkeyEvent)(keyEvent* ev); typedef void (CALLBACK* _GSkeyEvent)(keyEvent* ev);
typedef void (CALLBACK* _GSchangeSaveState)(int, const char* filename); typedef void (CALLBACK* _GSchangeSaveState)(int, const char* filename);
typedef void (CALLBACK* _GSirqCallback)(void (*callback)()); typedef void (CALLBACK* _GSirqCallback)(void (*callback)());
@ -494,7 +433,6 @@ typedef s32 (CALLBACK* _GSfreeze)(int mode, freezeData *data);
typedef void (CALLBACK* _GSconfigure)(); typedef void (CALLBACK* _GSconfigure)();
typedef s32(CALLBACK* _GStest)(); typedef s32(CALLBACK* _GStest)();
typedef void (CALLBACK* _GSabout)(); typedef void (CALLBACK* _GSabout)();
// PAD // PAD
typedef s32(CALLBACK* _PADinit)(u32 flags); typedef s32(CALLBACK* _PADinit)(u32 flags);
typedef s32(CALLBACK* _PADopen)(void *pDsp); typedef s32(CALLBACK* _PADopen)(void *pDsp);
@ -504,12 +442,10 @@ typedef keyEvent* (CALLBACK* _PADkeyEvent)();
typedef u8(CALLBACK* _PADstartPoll)(int pad); typedef u8(CALLBACK* _PADstartPoll)(int pad);
typedef u8(CALLBACK* _PADpoll)(u8 value); typedef u8(CALLBACK* _PADpoll)(u8 value);
typedef u32(CALLBACK* _PADquery)(); typedef u32(CALLBACK* _PADquery)();
typedef void (CALLBACK* _PADgsDriverInfo)(GSdriverInfo *info); typedef void (CALLBACK* _PADgsDriverInfo)(GSdriverInfo *info);
typedef void (CALLBACK* _PADconfigure)(); typedef void (CALLBACK* _PADconfigure)();
typedef s32(CALLBACK* _PADtest)(); typedef s32(CALLBACK* _PADtest)();
typedef void (CALLBACK* _PADabout)(); typedef void (CALLBACK* _PADabout)();
// SIO // SIO
typedef s32(CALLBACK* _SIOinit)(u32 port, u32 slot, SIOchangeSlotCB f); typedef s32(CALLBACK* _SIOinit)(u32 port, u32 slot, SIOchangeSlotCB f);
typedef s32(CALLBACK* _SIOopen)(void *pDsp); typedef s32(CALLBACK* _SIOopen)(void *pDsp);
@ -569,7 +505,6 @@ typedef void (CALLBACK* _CDVDconfigure)();
typedef s32(CALLBACK* _CDVDtest)(); typedef s32(CALLBACK* _CDVDtest)();
typedef void (CALLBACK* _CDVDabout)(); typedef void (CALLBACK* _CDVDabout)();
typedef void (CALLBACK* _CDVDnewDiskCB)(void (*callback)()); typedef void (CALLBACK* _CDVDnewDiskCB)(void (*callback)());
// DEV9 // DEV9
// NOTE: The read/write functions CANNOT use XMM/MMX regs // NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones // If you want to use them, need to save and restore current ones
@ -587,7 +522,6 @@ typedef void (CALLBACK* _DEV9readDMA8Mem)(u32 *pMem, int size);
typedef void (CALLBACK* _DEV9writeDMA8Mem)(u32 *pMem, int size); typedef void (CALLBACK* _DEV9writeDMA8Mem)(u32 *pMem, int size);
typedef void (CALLBACK* _DEV9irqCallback)(DEV9callback callback); typedef void (CALLBACK* _DEV9irqCallback)(DEV9callback callback);
typedef DEV9handler(CALLBACK* _DEV9irqHandler)(void); typedef DEV9handler(CALLBACK* _DEV9irqHandler)(void);
typedef s32(CALLBACK* _DEV9freeze)(int mode, freezeData *data); typedef s32(CALLBACK* _DEV9freeze)(int mode, freezeData *data);
typedef void (CALLBACK* _DEV9configure)(); typedef void (CALLBACK* _DEV9configure)();
typedef s32(CALLBACK* _DEV9test)(); typedef s32(CALLBACK* _DEV9test)();
@ -609,12 +543,10 @@ typedef void (CALLBACK* _USBwrite32)(u32 mem, u32 value);
typedef void (CALLBACK* _USBirqCallback)(USBcallback callback); typedef void (CALLBACK* _USBirqCallback)(USBcallback callback);
typedef USBhandler(CALLBACK* _USBirqHandler)(void); typedef USBhandler(CALLBACK* _USBirqHandler)(void);
typedef void (CALLBACK* _USBsetRAM)(void *mem); typedef void (CALLBACK* _USBsetRAM)(void *mem);
typedef s32(CALLBACK* _USBfreeze)(int mode, freezeData *data); typedef s32(CALLBACK* _USBfreeze)(int mode, freezeData *data);
typedef void (CALLBACK* _USBconfigure)(); typedef void (CALLBACK* _USBconfigure)();
typedef s32(CALLBACK* _USBtest)(); typedef s32(CALLBACK* _USBtest)();
typedef void (CALLBACK* _USBabout)(); typedef void (CALLBACK* _USBabout)();
//FW //FW
typedef s32(CALLBACK* _FWinit)(); typedef s32(CALLBACK* _FWinit)();
typedef s32(CALLBACK* _FWopen)(void *pDsp); typedef s32(CALLBACK* _FWopen)(void *pDsp);
@ -623,7 +555,6 @@ typedef void (CALLBACK* _FWshutdown)();
typedef u32(CALLBACK* _FWread32)(u32 mem); typedef u32(CALLBACK* _FWread32)(u32 mem);
typedef void (CALLBACK* _FWwrite32)(u32 mem, u32 value); typedef void (CALLBACK* _FWwrite32)(u32 mem, u32 value);
typedef void (CALLBACK* _FWirqCallback)(void (*callback)()); typedef void (CALLBACK* _FWirqCallback)(void (*callback)());
typedef s32(CALLBACK* _FWfreeze)(int mode, freezeData *data); typedef s32(CALLBACK* _FWfreeze)(int mode, freezeData *data);
typedef void (CALLBACK* _FWconfigure)(); typedef void (CALLBACK* _FWconfigure)();
typedef s32(CALLBACK* _FWtest)(); typedef s32(CALLBACK* _FWtest)();
@ -645,7 +576,6 @@ _GSgifTransfer3 GSgifTransfer3;
_GSgifSoftReset GSgifSoftReset; _GSgifSoftReset GSgifSoftReset;
_GSreadFIFO GSreadFIFO; _GSreadFIFO GSreadFIFO;
_GSreadFIFO2 GSreadFIFO2; _GSreadFIFO2 GSreadFIFO2;
_GSkeyEvent GSkeyEvent; _GSkeyEvent GSkeyEvent;
_GSchangeSaveState GSchangeSaveState; _GSchangeSaveState GSchangeSaveState;
_GSmakeSnapshot GSmakeSnapshot; _GSmakeSnapshot GSmakeSnapshot;
@ -665,7 +595,6 @@ _GSfreeze GSfreeze;
_GSconfigure GSconfigure; _GSconfigure GSconfigure;
_GStest GStest; _GStest GStest;
_GSabout GSabout; _GSabout GSabout;
// PAD1 // PAD1
_PADinit PAD1init; _PADinit PAD1init;
_PADopen PAD1open; _PADopen PAD1open;
@ -675,12 +604,10 @@ _PADkeyEvent PAD1keyEvent;
_PADstartPoll PAD1startPoll; _PADstartPoll PAD1startPoll;
_PADpoll PAD1poll; _PADpoll PAD1poll;
_PADquery PAD1query; _PADquery PAD1query;
_PADgsDriverInfo PAD1gsDriverInfo; _PADgsDriverInfo PAD1gsDriverInfo;
_PADconfigure PAD1configure; _PADconfigure PAD1configure;
_PADtest PAD1test; _PADtest PAD1test;
_PADabout PAD1about; _PADabout PAD1about;
// PAD2 // PAD2
_PADinit PAD2init; _PADinit PAD2init;
_PADopen PAD2open; _PADopen PAD2open;
@ -690,12 +617,10 @@ _PADkeyEvent PAD2keyEvent;
_PADstartPoll PAD2startPoll; _PADstartPoll PAD2startPoll;
_PADpoll PAD2poll; _PADpoll PAD2poll;
_PADquery PAD2query; _PADquery PAD2query;
_PADgsDriverInfo PAD2gsDriverInfo; _PADgsDriverInfo PAD2gsDriverInfo;
_PADconfigure PAD2configure; _PADconfigure PAD2configure;
_PADtest PAD2test; _PADtest PAD2test;
_PADabout PAD2about; _PADabout PAD2about;
// SIO[2] // SIO[2]
_SIOinit SIOinit[2][9]; _SIOinit SIOinit[2][9];
_SIOopen SIOopen[2][9]; _SIOopen SIOopen[2][9];
@ -725,13 +650,11 @@ _SPU2interruptDMA7 SPU2interruptDMA7;
_SPU2ReadMemAddr SPU2ReadMemAddr; _SPU2ReadMemAddr SPU2ReadMemAddr;
_SPU2WriteMemAddr SPU2WriteMemAddr; _SPU2WriteMemAddr SPU2WriteMemAddr;
_SPU2irqCallback SPU2irqCallback; _SPU2irqCallback SPU2irqCallback;
_SPU2async SPU2async; _SPU2async SPU2async;
_SPU2freeze SPU2freeze; _SPU2freeze SPU2freeze;
_SPU2configure SPU2configure; _SPU2configure SPU2configure;
_SPU2test SPU2test; _SPU2test SPU2test;
_SPU2about SPU2about; _SPU2about SPU2about;
// CDVD // CDVD
_CDVDinit CDVDinit; _CDVDinit CDVDinit;
_CDVDopen CDVDopen; _CDVDopen CDVDopen;
@ -747,12 +670,10 @@ _CDVDgetDiskType CDVDgetDiskType;
_CDVDgetTrayStatus CDVDgetTrayStatus; _CDVDgetTrayStatus CDVDgetTrayStatus;
_CDVDctrlTrayOpen CDVDctrlTrayOpen; _CDVDctrlTrayOpen CDVDctrlTrayOpen;
_CDVDctrlTrayClose CDVDctrlTrayClose; _CDVDctrlTrayClose CDVDctrlTrayClose;
_CDVDconfigure CDVDconfigure; _CDVDconfigure CDVDconfigure;
_CDVDtest CDVDtest; _CDVDtest CDVDtest;
_CDVDabout CDVDabout; _CDVDabout CDVDabout;
_CDVDnewDiskCB CDVDnewDiskCB; _CDVDnewDiskCB CDVDnewDiskCB;
// DEV9 // DEV9
_DEV9init DEV9init; _DEV9init DEV9init;
_DEV9open DEV9open; _DEV9open DEV9open;
@ -768,12 +689,10 @@ _DEV9readDMA8Mem DEV9readDMA8Mem;
_DEV9writeDMA8Mem DEV9writeDMA8Mem; _DEV9writeDMA8Mem DEV9writeDMA8Mem;
_DEV9irqCallback DEV9irqCallback; _DEV9irqCallback DEV9irqCallback;
_DEV9irqHandler DEV9irqHandler; _DEV9irqHandler DEV9irqHandler;
_DEV9configure DEV9configure; _DEV9configure DEV9configure;
_DEV9freeze DEV9freeze; _DEV9freeze DEV9freeze;
_DEV9test DEV9test; _DEV9test DEV9test;
_DEV9about DEV9about; _DEV9about DEV9about;
// USB // USB
_USBinit USBinit; _USBinit USBinit;
_USBopen USBopen; _USBopen USBopen;
@ -793,7 +712,6 @@ _USBconfigure USBconfigure;
_USBfreeze USBfreeze; _USBfreeze USBfreeze;
_USBtest USBtest; _USBtest USBtest;
_USBabout USBabout; _USBabout USBabout;
// FW // FW
_FWinit FWinit; _FWinit FWinit;
_FWopen FWopen; _FWopen FWopen;
@ -802,11 +720,9 @@ _FWshutdown FWshutdown;
_FWread32 FWread32; _FWread32 FWread32;
_FWwrite32 FWwrite32; _FWwrite32 FWwrite32;
_FWirqCallback FWirqCallback; _FWirqCallback FWirqCallback;
_FWconfigure FWconfigure; _FWconfigure FWconfigure;
_FWfreeze FWfreeze; _FWfreeze FWfreeze;
_FWtest FWtest; _FWtest FWtest;
_FWabout FWabout; _FWabout FWabout;
#endif #endif
#endif /* __PS2EDEFS_H__ */ #endif /* __PS2EDEFS_H__ */

View File

@ -11,65 +11,52 @@
// Basic types // Basic types
#if defined(_MSC_VER) #if defined(_MSC_VER)
typedef __int8 s8; typedef __int8 s8;
typedef __int16 s16; typedef __int16 s16;
typedef __int32 s32; typedef __int32 s32;
typedef __int64 s64; typedef __int64 s64;
typedef unsigned __int8 u8; typedef unsigned __int8 u8;
typedef unsigned __int16 u16; typedef unsigned __int16 u16;
typedef unsigned __int32 u32; typedef unsigned __int32 u32;
typedef unsigned __int64 u64; typedef unsigned __int64 u64;
#if defined(__x86_64__) #if defined(__x86_64__)
typedef u64 uptr; typedef u64 uptr;
#else #else
typedef u32 uptr; typedef u32 uptr;
#endif #endif
#define PCSX2_ALIGNED16(x) __declspec(align(16)) x #define PCSX2_ALIGNED16(x) __declspec(align(16)) x
#else #else
typedef char s8; typedef char s8;
typedef short s16; typedef short s16;
typedef int s32; typedef int s32;
typedef long long s64; typedef long long s64;
typedef unsigned char u8; typedef unsigned char u8;
typedef unsigned short u16; typedef unsigned short u16;
typedef unsigned int u32; typedef unsigned int u32;
typedef unsigned long long u64; typedef unsigned long long u64;
#if defined(__x86_64__) #if defined(__x86_64__)
typedef u64 uptr; typedef u64 uptr;
#else #else
typedef u32 uptr; typedef u32 uptr;
#endif #endif
#ifdef __LINUX__ #ifdef __LINUX__
typedef union _LARGE_INTEGER typedef union _LARGE_INTEGER
{ {
long long QuadPart; long long QuadPart;
} LARGE_INTEGER; } LARGE_INTEGER;
#endif #endif
#if defined(__MINGW32__) #if defined(__MINGW32__)
#define PCSX2_ALIGNED16(x) __declspec(align(16)) x #define PCSX2_ALIGNED16(x) __declspec(align(16)) x
#else #else
#define PCSX2_ALIGNED16(x) x __attribute((aligned(16))) #define PCSX2_ALIGNED16(x) x __attribute((aligned(16)))
#endif #endif
#ifndef __forceinline #ifndef __forceinline
#define __forceinline inline #define __forceinline inline
#endif #endif
#endif #endif
typedef struct
typedef struct { {
int size; int size;
s8 *data; s8 *data;
} freezeData; } freezeData;
#endif /* __PS2ETYPES_H__ */ #endif /* __PS2ETYPES_H__ */

View File

@ -1,774 +1,393 @@
/* CD.c /* CD.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <windows.h> #include <windows.h>
#include <ddk/ntddcdrm.h> // IOCTL_CDROM... #include <ddk/ntddcdrm.h> // IOCTL_CDROM...
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
#define CDVDdefs #define CDVDdefs
#include "PS2Edefs.h" #include "PS2Edefs.h"
#include "logfile.h" #include "logfile.h"
#include "../convert.h" // MSFtoLBA(), HEXTOBCD() #include "../convert.h" // MSFtoLBA(), HEXTOBCD()
#include "actualfile.h" #include "actualfile.h"
#include "device.h" // tocbuffer[], FinishCommand() #include "device.h" // tocbuffer[], FinishCommand()
#include "CD.h" #include "CD.h"
int actualcdmode; // -1=ReadFile, 0=YellowMode2, 1=XAForm2, 2=CDDA int actualcdmode; // -1=ReadFile, 0=YellowMode2, 1=XAForm2, 2=CDDA
DWORD cdblocksize; // 2048 to 2352 DWORD cdblocksize; // 2048 to 2352
int cdoffset; // 0, 8, 16, or 24 int cdoffset; // 0, 8, 16, or 24
int cdmode; int cdmode;
void InitCDInfo()
{
void InitCDInfo() {
actualcdmode = -1; actualcdmode = -1;
cdblocksize = 2048; cdblocksize = 2048;
cdmode = -1; cdmode = -1;
} // END InitCDInfo() } // END InitCDInfo()
s32 CDreadTrackPass(u32 lsn, int mode, u8 *buffer)
{
s32 CDreadTrackPass(u32 lsn, int mode, u8 *buffer) {
RAW_READ_INFO rawinfo; RAW_READ_INFO rawinfo;
BOOL boolresult; BOOL boolresult;
DWORD byteswritten; DWORD byteswritten;
DWORD errcode; DWORD errcode;
LARGE_INTEGER targetpos; LARGE_INTEGER targetpos;
int i; int i;
if ((actualcdmode < -1) || (actualcdmode > 2)) return(-1); if ((actualcdmode < -1) || (actualcdmode > 2)) return(-1);
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD CD: CDreadTrack(%llu, %i)", lsn, actualcdmode); PrintLog("CDVD CD: CDreadTrack(%llu, %i)", lsn, actualcdmode);
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
if (actualcdmode >= 0)
{
if(actualcdmode >= 0) {
rawinfo.DiskOffset.QuadPart = lsn * 2048; // Yes, 2048. rawinfo.DiskOffset.QuadPart = lsn * 2048; // Yes, 2048.
rawinfo.SectorCount = 1; rawinfo.SectorCount = 1;
rawinfo.TrackMode = actualcdmode; rawinfo.TrackMode = actualcdmode;
boolresult = DeviceIoControl(devicehandle, boolresult = DeviceIoControl(devicehandle,
IOCTL_CDROM_RAW_READ, IOCTL_CDROM_RAW_READ,
&rawinfo, &rawinfo,
sizeof(RAW_READ_INFO), sizeof(RAW_READ_INFO),
buffer, buffer,
2352, 2352,
&byteswritten, &byteswritten,
&waitevent); &waitevent);
errcode = FinishCommand(boolresult); errcode = FinishCommand(boolresult);
if (errcode != 0)
{
if(errcode != 0) {
#ifdef VERBOSE_WARNING_DEVICE #ifdef VERBOSE_WARNING_DEVICE
PrintLog("CDVDiso CD: Couldn't read a sector raw!"); PrintLog("CDVDiso CD: Couldn't read a sector raw!");
PrintError("CDVDiso CD", errcode); PrintError("CDVDiso CD", errcode);
#endif /* VERBOSE_WARNING_DEVICE */ #endif /* VERBOSE_WARNING_DEVICE */
return(-1); return(-1);
} // ENDIF- Couldn't read a raw sector? Maybe not a CD. } // ENDIF- Couldn't read a raw sector? Maybe not a CD.
}
else
} else { {
targetpos.QuadPart = lsn * 2048; targetpos.QuadPart = lsn * 2048;
waitevent.Offset = targetpos.LowPart; waitevent.Offset = targetpos.LowPart;
waitevent.OffsetHigh = targetpos.HighPart; waitevent.OffsetHigh = targetpos.HighPart;
boolresult = ReadFile(devicehandle, boolresult = ReadFile(devicehandle,
buffer + 24, buffer + 24,
2048, 2048,
&byteswritten, &byteswritten,
&waitevent); &waitevent);
errcode = FinishCommand(boolresult); errcode = FinishCommand(boolresult);
if (errcode != 0)
{
if(errcode != 0) {
#ifdef VERBOSE_WARNING_DEVICE #ifdef VERBOSE_WARNING_DEVICE
PrintLog("CDVDiso CD: Couldn't read a cooked sector!"); PrintLog("CDVDiso CD: Couldn't read a cooked sector!");
PrintError("CDVDiso CD", errcode); PrintError("CDVDiso CD", errcode);
#endif /* VERBOSE_WARNING_DEVICE */ #endif /* VERBOSE_WARNING_DEVICE */
return(-1); return(-1);
} // ENDIF- Trouble with seek? Report it. } // ENDIF- Trouble with seek? Report it.
for (i = 0; i < 24; i++) *(buffer + i) = 0; for (i = 0; i < 24; i++) *(buffer + i) = 0;
for (i = 24 + 2048; i < 2352; i++) *(buffer + i) = 0; for (i = 24 + 2048; i < 2352; i++) *(buffer + i) = 0;
} // ENDIF- Could we read a raw sector? Read another one! } // ENDIF- Could we read a raw sector? Read another one!
if (boolresult == FALSE)
{
if(boolresult == FALSE) {
boolresult = GetOverlappedResult(devicehandle, boolresult = GetOverlappedResult(devicehandle,
&waitevent, &waitevent,
&byteswritten, &byteswritten,
FALSE); FALSE);
} // ENDIF- Did the initial call not complete? Get byteswritten for } // ENDIF- Did the initial call not complete? Get byteswritten for
// the completed call. // the completed call.
if (byteswritten < 2048)
{
if(byteswritten < 2048) {
#ifdef VERBOSE_WARNING_DEVICE #ifdef VERBOSE_WARNING_DEVICE
errcode = GetLastError(); errcode = GetLastError();
PrintLog("CDVDiso CD: Short block! only got %u out of %u bytes", PrintLog("CDVDiso CD: Short block! only got %u out of %u bytes",
byteswritten, cdblocksize); byteswritten, cdblocksize);
PrintError("CDVDiso CD", errcode); PrintError("CDVDiso CD", errcode);
#endif /* VERBOSE_WARNING_DEVICE */ #endif /* VERBOSE_WARNING_DEVICE */
return(-1); return(-1);
} // ENDIF- Couldn't read a raw sector? Maybe not a CD. } // ENDIF- Couldn't read a raw sector? Maybe not a CD.
cdmode = mode; cdmode = mode;
cdblocksize = byteswritten; cdblocksize = byteswritten;
return(0); return(0);
} // END CDreadTrackPass() } // END CDreadTrackPass()
s32 CDreadTrack(u32 lsn, int mode, u8 *buffer)
{
s32 CDreadTrack(u32 lsn, int mode, u8 *buffer) {
int retval; int retval;
int lastmode; int lastmode;
int i; int i;
retval = CDreadTrackPass(lsn, mode, buffer); retval = CDreadTrackPass(lsn, mode, buffer);
if (retval >= 0) return(retval); if (retval >= 0) return(retval);
#ifdef VERBOSE_WARNING_DEVICE #ifdef VERBOSE_WARNING_DEVICE
PrintLog("CDVDiso CD: Same mode doesn't work. Scanning..."); PrintLog("CDVDiso CD: Same mode doesn't work. Scanning...");
#endif /* VERBOSE_WARNING_DEVICE */ #endif /* VERBOSE_WARNING_DEVICE */
lastmode = actualcdmode; lastmode = actualcdmode;
actualcdmode = 2; actualcdmode = 2;
while (actualcdmode >= -1)
while(actualcdmode >= -1) { {
retval = CDreadTrackPass(lsn, mode, buffer); retval = CDreadTrackPass(lsn, mode, buffer);
if (retval >= 0) return(retval); if (retval >= 0) return(retval);
actualcdmode--; actualcdmode--;
} // ENDWHILE- Searching each mode for a way to read the sector } // ENDWHILE- Searching each mode for a way to read the sector
actualcdmode = lastmode; // None worked? Go back to first mode. actualcdmode = lastmode; // None worked? Go back to first mode.
#ifdef VERBOSE_WARNING_DEVICE #ifdef VERBOSE_WARNING_DEVICE
PrintLog("CDVDiso CD: No modes work. Failing sector!"); PrintLog("CDVDiso CD: No modes work. Failing sector!");
#endif /* VERBOSE_WARNING_DEVICE */ #endif /* VERBOSE_WARNING_DEVICE */
for (i = 0; i < 2352; i++) *(buffer + i) = 0; for (i = 0; i < 2352; i++) *(buffer + i) = 0;
return(-1); return(-1);
} // END CDreadTrack() } // END CDreadTrack()
s32 CDgetBufferOffset()
{
s32 CDgetBufferOffset() {
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD CD: CDgetBufferOffset()"); PrintLog("CDVD CD: CDgetBufferOffset()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
// Send a whole CDDA record in? // Send a whole CDDA record in?
if ((actualcdmode == CDDA) && (cdmode == CDVD_MODE_2352)) return(0); if ((actualcdmode == CDDA) && (cdmode == CDVD_MODE_2352)) return(0);
// Otherwise, send the start of the data block in... // Otherwise, send the start of the data block in...
return(cdoffset); return(cdoffset);
} // END CDgetBufferOffset() } // END CDgetBufferOffset()
s32 CDreadSubQ()
{
s32 CDreadSubQ() {
return(-1); return(-1);
} // END CDreadSubQ() } // END CDreadSubQ()
s32 CDgetTN(cdvdTN *cdvdtn)
{
s32 CDgetTN(cdvdTN *cdvdtn) {
cdvdtn->strack = BCDTOHEX(tocbuffer[7]); cdvdtn->strack = BCDTOHEX(tocbuffer[7]);
cdvdtn->etrack = BCDTOHEX(tocbuffer[17]); cdvdtn->etrack = BCDTOHEX(tocbuffer[17]);
return(0); return(0);
} // END CDgetTN() } // END CDgetTN()
s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd)
{
s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd) {
u8 actualtrack; u8 actualtrack;
int pos; int pos;
char temptime[3]; char temptime[3];
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVDiso CD: CDgetTD()"); PrintLog("CDVDiso CD: CDgetTD()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
actualtrack = newtrack; actualtrack = newtrack;
if (actualtrack == 0xaa) actualtrack = 0; if (actualtrack == 0xaa) actualtrack = 0;
if (actualtrack == 0)
{
if(actualtrack == 0) {
cdvdtd->type = 0; cdvdtd->type = 0;
temptime[0] = BCDTOHEX(tocbuffer[27]); temptime[0] = BCDTOHEX(tocbuffer[27]);
temptime[1] = BCDTOHEX(tocbuffer[28]); temptime[1] = BCDTOHEX(tocbuffer[28]);
temptime[2] = BCDTOHEX(tocbuffer[29]); temptime[2] = BCDTOHEX(tocbuffer[29]);
cdvdtd->lsn = MSFtoLBA(temptime); cdvdtd->lsn = MSFtoLBA(temptime);
}
} else { else
{
pos = actualtrack * 10; pos = actualtrack * 10;
pos += 30; pos += 30;
cdvdtd->type = tocbuffer[pos]; cdvdtd->type = tocbuffer[pos];
temptime[0] = BCDTOHEX(tocbuffer[pos + 7]); temptime[0] = BCDTOHEX(tocbuffer[pos + 7]);
temptime[1] = BCDTOHEX(tocbuffer[pos + 8]); temptime[1] = BCDTOHEX(tocbuffer[pos + 8]);
temptime[2] = BCDTOHEX(tocbuffer[pos + 9]); temptime[2] = BCDTOHEX(tocbuffer[pos + 9]);
cdvdtd->lsn = MSFtoLBA(temptime); cdvdtd->lsn = MSFtoLBA(temptime);
} // ENDIF- Whole disc? (or single track?) } // ENDIF- Whole disc? (or single track?)
return(0); return(0);
} // END CDgetTD() } // END CDgetTD()
s32 CDgetDiskType()
{
s32 CDgetDiskType() {
CDROM_TOC cdinfo; CDROM_TOC cdinfo;
BOOL boolresult; BOOL boolresult;
int retval; int retval;
DWORD byteswritten; DWORD byteswritten;
DWORD errcode; DWORD errcode;
u8 iso9660name[] = "CD001\0"; u8 iso9660name[] = "CD001\0";
u8 playstationname[] = "PLAYSTATION\0"; u8 playstationname[] = "PLAYSTATION\0";
u8 ps1name[] = "CD-XA001\0"; u8 ps1name[] = "CD-XA001\0";
u8 tempbuffer[2448]; u8 tempbuffer[2448];
int tempdisctype; int tempdisctype;
int i; int i;
int pos; int pos;
unsigned long volumesize; unsigned long volumesize;
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVDiso CD: CDgetDiskType()"); PrintLog("CDVDiso CD: CDgetDiskType()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
tempdisctype = CDVD_TYPE_UNKNOWN; tempdisctype = CDVD_TYPE_UNKNOWN;
actualcdmode = 2; actualcdmode = 2;
retval = CDreadTrack(16, CDVD_MODE_2048, tempbuffer); retval = CDreadTrack(16, CDVD_MODE_2048, tempbuffer);
if (retval < 0)
if(retval < 0) { {
disctype = tempdisctype; disctype = tempdisctype;
return(-1); return(-1);
} // ENDIF- Couldn't read the directory sector? Abort. } // ENDIF- Couldn't read the directory sector? Abort.
disctype = CDVD_TYPE_DETCTCD; disctype = CDVD_TYPE_DETCTCD;
tempdisctype = CDVD_TYPE_CDDA; tempdisctype = CDVD_TYPE_CDDA;
cdoffset = 0; cdoffset = 0;
i = 0; i = 0;
while ((cdoffset <= 24) && (iso9660name[i] != 0))
while((cdoffset <= 24) && (iso9660name[i] != 0)) { {
i = 0; i = 0;
while ((iso9660name[i] != 0) && while ((iso9660name[i] != 0) &&
(iso9660name[i] == tempbuffer[cdoffset + 1 + i])) i++; (iso9660name[i] == tempbuffer[cdoffset + 1 + i])) i++;
if (iso9660name[i] != 0) cdoffset += 8; if (iso9660name[i] != 0) cdoffset += 8;
} // ENDWHILE- Trying to find a working offset for a ISO9660 record. } // ENDWHILE- Trying to find a working offset for a ISO9660 record.
if (iso9660name[i] != 0)
{
if(iso9660name[i] != 0) {
#ifdef VERBOSE_DISC_TYPE #ifdef VERBOSE_DISC_TYPE
PrintLog("Detected a CDDA (Music CD)."); PrintLog("Detected a CDDA (Music CD).");
#endif /* VERBOSE_DISC_TYPE */ #endif /* VERBOSE_DISC_TYPE */
tempdisctype = CDVD_TYPE_CDDA; tempdisctype = CDVD_TYPE_CDDA;
tocbuffer[0] = 0x01; tocbuffer[0] = 0x01;
}
else
} else { {
tocbuffer[0] = 0x41; tocbuffer[0] = 0x41;
i = 0; i = 0;
while ((playstationname[i] != 0) && while ((playstationname[i] != 0) &&
(playstationname[i] == tempbuffer[cdoffset + 8 + i])) i++; (playstationname[i] == tempbuffer[cdoffset + 8 + i])) i++;
if (playstationname[i] != 0)
if(playstationname[i] != 0) { {
#ifdef VERBOSE_DISC_TYPE #ifdef VERBOSE_DISC_TYPE
PrintLog("Detected a non-Playstation CD."); PrintLog("Detected a non-Playstation CD.");
#endif /* VERBOSE_DISC_TYPE */ #endif /* VERBOSE_DISC_TYPE */
tempdisctype = CDVD_TYPE_UNKNOWN; tempdisctype = CDVD_TYPE_UNKNOWN;
}
else
{
} else {
i = 0; i = 0;
while ((ps1name[i] != 0) && while ((ps1name[i] != 0) &&
(ps1name[i] == tempbuffer[cdoffset + 1024 + i])) i++; (ps1name[i] == tempbuffer[cdoffset + 1024 + i])) i++;
if (ps1name[i] != 0)
if(ps1name[i] != 0) { {
#ifdef VERBOSE_DISC_TYPE #ifdef VERBOSE_DISC_TYPE
PrintLog("Detected a Playstation 2 CD."); PrintLog("Detected a Playstation 2 CD.");
#endif /* VERBOSE_DISC_TYPE */ #endif /* VERBOSE_DISC_TYPE */
tempdisctype = CDVD_TYPE_PS2CD; tempdisctype = CDVD_TYPE_PS2CD;
}
} else { else
{
#ifdef VERBOSE_DISC_TYPE #ifdef VERBOSE_DISC_TYPE
PrintLog("Detected a Playstation CD."); PrintLog("Detected a Playstation CD.");
#endif /* VERBOSE_DISC_TYPE */ #endif /* VERBOSE_DISC_TYPE */
tempdisctype = CDVD_TYPE_PSCD; tempdisctype = CDVD_TYPE_PSCD;
} // ENDIF- Is this not a PlayStation Disc? } // ENDIF- Is this not a PlayStation Disc?
} // ENDIF- Is this not a PlayStation Disc? } // ENDIF- Is this not a PlayStation Disc?
} // ENDIF- Is this not an ISO9660 CD? (a CDDA, in other words?) } // ENDIF- Is this not an ISO9660 CD? (a CDDA, in other words?)
// Build the Fake TOC // Build the Fake TOC
tocbuffer[2] = 0xA0; tocbuffer[2] = 0xA0;
tocbuffer[7] = HEXTOBCD(1); // Starting Track tocbuffer[7] = HEXTOBCD(1); // Starting Track
tocbuffer[12] = 0xA1; tocbuffer[12] = 0xA1;
tocbuffer[17] = HEXTOBCD(1); // Ending Track tocbuffer[17] = HEXTOBCD(1); // Ending Track
volumesize = tempbuffer[84]; // Volume size (big endian) volumesize = tempbuffer[84]; // Volume size (big endian)
volumesize *= 256; volumesize *= 256;
volumesize += tempbuffer[85]; volumesize += tempbuffer[85];
volumesize *= 256; volumesize *= 256;
volumesize += tempbuffer[86]; volumesize += tempbuffer[86];
volumesize *= 256; volumesize *= 256;
volumesize += tempbuffer[87]; volumesize += tempbuffer[87];
#ifdef VERBOSE_DISC_INFO #ifdef VERBOSE_DISC_INFO
if (tempdisctype != CDVD_TYPE_CDDA)
if(tempdisctype != CDVD_TYPE_CDDA) { {
PrintLog("CDVDiso CD: ISO9660 size %llu", volumesize); PrintLog("CDVDiso CD: ISO9660 size %llu", volumesize);
} // ENDIF- Data CD? Print size in blocks. } // ENDIF- Data CD? Print size in blocks.
#endif /* VERBOSE_DISC_INFO */ #endif /* VERBOSE_DISC_INFO */
LBAtoMSF(volumesize, &tocbuffer[27]); LBAtoMSF(volumesize, &tocbuffer[27]);
tocbuffer[27] = HEXTOBCD(tocbuffer[27]); tocbuffer[27] = HEXTOBCD(tocbuffer[27]);
tocbuffer[28] = HEXTOBCD(tocbuffer[28]); tocbuffer[28] = HEXTOBCD(tocbuffer[28]);
tocbuffer[29] = HEXTOBCD(tocbuffer[29]); tocbuffer[29] = HEXTOBCD(tocbuffer[29]);
tocbuffer[40] = 0x02; // Data Mode tocbuffer[40] = 0x02; // Data Mode
tocbuffer[42] = 0x01; // Track # tocbuffer[42] = 0x01; // Track #
LBAtoMSF(0, &tocbuffer[47]); LBAtoMSF(0, &tocbuffer[47]);
tocbuffer[47] = HEXTOBCD(tocbuffer[47]); tocbuffer[47] = HEXTOBCD(tocbuffer[47]);
tocbuffer[48] = HEXTOBCD(tocbuffer[48]); tocbuffer[48] = HEXTOBCD(tocbuffer[48]);
tocbuffer[49] = HEXTOBCD(tocbuffer[49]); tocbuffer[49] = HEXTOBCD(tocbuffer[49]);
// Can we get the REAL TOC? // Can we get the REAL TOC?
boolresult = DeviceIoControl(devicehandle, boolresult = DeviceIoControl(devicehandle,
IOCTL_CDROM_READ_TOC, IOCTL_CDROM_READ_TOC,
NULL, NULL,
0, 0,
&cdinfo, &cdinfo,
sizeof(CDROM_TOC), sizeof(CDROM_TOC),
&byteswritten, &byteswritten,
NULL); NULL);
if (boolresult == FALSE)
{
if(boolresult == FALSE) {
#ifdef VERBOSE_WARNING_DEVICE #ifdef VERBOSE_WARNING_DEVICE
errcode = GetLastError(); errcode = GetLastError();
PrintLog("CDVDiso CD: Can't get TOC!"); PrintLog("CDVDiso CD: Can't get TOC!");
PrintError("CDVDiso CD", errcode); PrintError("CDVDiso CD", errcode);
#endif /* VERBOSE_WARNING_DEVICE */ #endif /* VERBOSE_WARNING_DEVICE */
disctype = tempdisctype; disctype = tempdisctype;
return(disctype); return(disctype);
} // ENDIF- Can't read the TOC? Accept the fake TOC then. } // ENDIF- Can't read the TOC? Accept the fake TOC then.
// Fill in the pieces of the REAL TOC. // Fill in the pieces of the REAL TOC.
#ifdef VERBOSE_DISC_INFO #ifdef VERBOSE_DISC_INFO
PrintLog("CDVDiso CD: TOC First Track: %u Last Track: %u", PrintLog("CDVDiso CD: TOC First Track: %u Last Track: %u",
cdinfo.FirstTrack, cdinfo.LastTrack); cdinfo.FirstTrack, cdinfo.LastTrack);
#endif /* VERBOSE_DISC_INFO */ #endif /* VERBOSE_DISC_INFO */
tocbuffer[7] = HEXTOBCD(cdinfo.FirstTrack); tocbuffer[7] = HEXTOBCD(cdinfo.FirstTrack);
tocbuffer[17] = HEXTOBCD(cdinfo.LastTrack); tocbuffer[17] = HEXTOBCD(cdinfo.LastTrack);
// for(i = cdinfo.FirstTrack; i <= cdinfo.LastTrack; i++) { // for(i = cdinfo.FirstTrack; i <= cdinfo.LastTrack; i++) {
for (i = 0; i <= cdinfo.LastTrack - cdinfo.FirstTrack; i++)
for(i = 0; i <= cdinfo.LastTrack - cdinfo.FirstTrack; i++) { {
#ifdef VERBOSE_DISC_INFO #ifdef VERBOSE_DISC_INFO
PrintLog("CDVDiso CD: TOC Track %u Disc Size: %u:%u.%u Data Mode %u", PrintLog("CDVDiso CD: TOC Track %u Disc Size: %u:%u.%u Data Mode %u",
cdinfo.TrackData[i].TrackNumber, cdinfo.TrackData[i].TrackNumber,
cdinfo.TrackData[i].Address[1] * 1, cdinfo.TrackData[i].Address[1] * 1,
cdinfo.TrackData[i].Address[2] * 1, cdinfo.TrackData[i].Address[2] * 1,
cdinfo.TrackData[i].Address[3] * 1, cdinfo.TrackData[i].Address[3] * 1,
cdinfo.TrackData[i].Control * 1); cdinfo.TrackData[i].Control * 1);
#endif /* VERBOSE_DISC_INFO */ #endif /* VERBOSE_DISC_INFO */
pos = i * 10 + 40; pos = i * 10 + 40;
tocbuffer[pos] = cdinfo.TrackData[i].Control; tocbuffer[pos] = cdinfo.TrackData[i].Control;
tocbuffer[pos + 2] = HEXTOBCD(i + 1); tocbuffer[pos + 2] = HEXTOBCD(i + 1);
tocbuffer[pos + 7] = HEXTOBCD(cdinfo.TrackData[i].Address[1]); tocbuffer[pos + 7] = HEXTOBCD(cdinfo.TrackData[i].Address[1]);
tocbuffer[pos + 8] = HEXTOBCD(cdinfo.TrackData[i].Address[2]); tocbuffer[pos + 8] = HEXTOBCD(cdinfo.TrackData[i].Address[2]);
tocbuffer[pos + 9] = HEXTOBCD(cdinfo.TrackData[i].Address[3]); tocbuffer[pos + 9] = HEXTOBCD(cdinfo.TrackData[i].Address[3]);
} // NEXT i- Transferring Track data to the PS2 TOC } // NEXT i- Transferring Track data to the PS2 TOC
#ifdef VERBOSE_DISC_INFO #ifdef VERBOSE_DISC_INFO
PrintLog("CDVDiso CD: TOC Disc Size: %u:%u.%u", PrintLog("CDVDiso CD: TOC Disc Size: %u:%u.%u",
cdinfo.TrackData[i].Address[1] * 1, cdinfo.TrackData[i].Address[1] * 1,
cdinfo.TrackData[i].Address[2] * 1, cdinfo.TrackData[i].Address[2] * 1,
cdinfo.TrackData[i].Address[3] * 1); cdinfo.TrackData[i].Address[3] * 1);
#endif /* VERBOSE_DISC_INFO */ #endif /* VERBOSE_DISC_INFO */
tocbuffer[27] = HEXTOBCD(cdinfo.TrackData[i].Address[1]); tocbuffer[27] = HEXTOBCD(cdinfo.TrackData[i].Address[1]);
tocbuffer[28] = HEXTOBCD(cdinfo.TrackData[i].Address[2]); tocbuffer[28] = HEXTOBCD(cdinfo.TrackData[i].Address[2]);
tocbuffer[29] = HEXTOBCD(cdinfo.TrackData[i].Address[3]); tocbuffer[29] = HEXTOBCD(cdinfo.TrackData[i].Address[3]);
disctype = tempdisctype; disctype = tempdisctype;
return(disctype); return(disctype);
} // END CDgetDiskType() } // END CDgetDiskType()

View File

@ -1,88 +1,44 @@
/* CD.h /* CD.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef CD_H #ifndef CD_H
#define CD_H #define CD_H
#include <windows.h> // DWORD #include <windows.h> // DWORD
#define CDVDdefs #define CDVDdefs
#include "PS2Edefs.h" #include "PS2Edefs.h"
extern DWORD cdblocksize; extern DWORD cdblocksize;
extern void InitCDInfo(); extern void InitCDInfo();
extern s32 CDreadTrack(u32 lsn, int mode, u8 *buffer); extern s32 CDreadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 CDgetBufferOffset(); extern s32 CDgetBufferOffset();
extern s32 CDreadSubQ(); extern s32 CDreadSubQ();
extern s32 CDgetTN(cdvdTN *cdvdtn); extern s32 CDgetTN(cdvdTN *cdvdtn);
extern s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd); extern s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd);
extern s32 CDgetDiskType(); extern s32 CDgetDiskType();
#endif /* CD_H */ #endif /* CD_H */

View File

@ -17,11 +17,8 @@
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <windows.h> // BOOL, CALLBACK, APIENTRY #include <windows.h> // BOOL, CALLBACK, APIENTRY
#include <windef.h> // NULL #include <windef.h> // NULL
#define CDVDdefs #define CDVDdefs
#include "../PS2Edefs.h" #include "../PS2Edefs.h"
@ -37,23 +34,18 @@
#include "conversionbox.h" // Initialize conversionboxwindow #include "conversionbox.h" // Initialize conversionboxwindow
#include "devicebox.h" // Initialize deviceboxwindow #include "devicebox.h" // Initialize deviceboxwindow
#include "CDVDiso.h" #include "CDVDiso.h"
struct IsoFile *isofile; struct IsoFile *isofile;
char isobuffer[2448]; char isobuffer[2448];
char isocdcheck[2048]; char isocdcheck[2048];
int isomode; int isomode;
int deviceopencount; int deviceopencount;
HINSTANCE progmodule; HINSTANCE progmodule;
BOOL APIENTRY DllMain(HANDLE hModule, BOOL APIENTRY DllMain(HANDLE hModule,
DWORD param, DWORD param,
LPVOID reserved) { LPVOID reserved)
{
switch (param)
switch(param) { {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
progmodule = hModule; progmodule = hModule;
// mainboxwindow = NULL; // mainboxwindow = NULL;
@ -73,43 +65,38 @@ BOOL APIENTRY DllMain(HANDLE hModule,
return(TRUE); return(TRUE);
break; break;
} // ENDSWITCH param- What does the OS want with us? } // ENDSWITCH param- What does the OS want with us?
return(FALSE); // Wasn't on list? Wasn't handled. return(FALSE); // Wasn't on list? Wasn't handled.
} // END DllMain() } // END DllMain()
char* CALLBACK PS2EgetLibName()
char* CALLBACK PS2EgetLibName() { {
return(libname); return(libname);
} // END PS2EgetLibName() } // END PS2EgetLibName()
u32 CALLBACK PS2EgetLibType()
u32 CALLBACK PS2EgetLibType() { {
return(PS2E_LT_CDVD); return(PS2E_LT_CDVD);
} // END PS2getLibType() } // END PS2getLibType()
u32 CALLBACK PS2EgetLibVersion2(u32 type)
u32 CALLBACK PS2EgetLibVersion2(u32 type) { {
return((version << 16) | (revision << 8) | build); return((version << 16) | (revision << 8) | build);
} // END PS2EgetLibVersion2() } // END PS2EgetLibVersion2()
s32 CALLBACK CDVDinit()
s32 CALLBACK CDVDinit() { {
int i; int i;
InitLog(); InitLog();
if (OpenLog() != 0) return(-1); // Couldn't open Log File? Abort. if (OpenLog() != 0) return(-1); // Couldn't open Log File? Abort.
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDinit()"); PrintLog("CDVDiso interface: CDVDinit()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
InitConf(); InitConf();
isofile = NULL; isofile = NULL;
isomode = -1; isomode = -1;
deviceopencount = 0; deviceopencount = 0;
for (i = 0; i < 2048; i++) isocdcheck[i] = 0; for (i = 0; i < 2048; i++) isocdcheck[i] = 0;
mainboxwindow = NULL; mainboxwindow = NULL;
progressboxwindow = NULL; progressboxwindow = NULL;
conversionboxwindow = NULL; conversionboxwindow = NULL;
@ -117,38 +104,31 @@ s32 CALLBACK CDVDinit() {
return(0); return(0);
} // END CDVDinit() } // END CDVDinit()
void CALLBACK CDVDshutdown()
{
void CALLBACK CDVDshutdown() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDshutdown()"); PrintLog("CDVDiso interface: CDVDshutdown()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
isofile = IsoFileClose(isofile); isofile = IsoFileClose(isofile);
// Close Windows as well? (Just in case) // Close Windows as well? (Just in case)
CloseLog(); CloseLog();
} // END CDVDshutdown() } // END CDVDshutdown()
s32 CALLBACK CDVDopen(const char* pTitleFilename)
s32 CALLBACK CDVDopen(const char* pTitleFilename) { {
HWND lastwindow; HWND lastwindow;
int i; int i;
int retval; int retval;
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDopen()"); PrintLog("CDVDiso interface: CDVDopen()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
lastwindow = GetActiveWindow(); lastwindow = GetActiveWindow();
LoadConf(); LoadConf();
if (pTitleFilename != NULL) strcpy(conf.isoname, pTitleFilename); if (pTitleFilename != NULL) strcpy(conf.isoname, pTitleFilename);
if ((conf.isoname[0] == 0) || (conf.isoname[0] == '[') || if ((conf.isoname[0] == 0) || (conf.isoname[0] == '[') ||
((conf.startconfigure == 1) && (deviceopencount == 0)) || ((conf.startconfigure == 1) && (deviceopencount == 0)) ||
((conf.restartconfigure == 1) && (deviceopencount > 0))) { ((conf.restartconfigure == 1) && (deviceopencount > 0)))
{
DialogBox(progmodule, DialogBox(progmodule,
MAKEINTRESOURCE(DLG_0200), MAKEINTRESOURCE(DLG_0200),
lastwindow, lastwindow,
@ -158,9 +138,9 @@ s32 CALLBACK CDVDopen(const char* pTitleFilename) {
// Blank out the name in config file afterwards? Seems excessive. // Blank out the name in config file afterwards? Seems excessive.
} // ENDIF- Haven't initialized the configure program yet? Do so now. } // ENDIF- Haven't initialized the configure program yet? Do so now.
lastwindow = NULL; lastwindow = NULL;
isofile = IsoFileOpenForRead(conf.isoname); isofile = IsoFileOpenForRead(conf.isoname);
if(isofile == NULL) { if (isofile == NULL)
{
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: Failed to open ISO file!"); PrintLog("CDVDiso interface: Failed to open ISO file!");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
@ -168,25 +148,22 @@ s32 CALLBACK CDVDopen(const char* pTitleFilename) {
for (i = 0; i < 2048; i++) isocdcheck[i] = 0; for (i = 0; i < 2048; i++) isocdcheck[i] = 0;
return(0); return(0);
} // ENDIF- Trouble opening file? Abort. } // ENDIF- Trouble opening file? Abort.
retval = IsoFileSeek(isofile, 16); retval = IsoFileSeek(isofile, 16);
if (retval != 0) return(-1); if (retval != 0) return(-1);
retval = IsoFileRead(isofile, isobuffer); retval = IsoFileRead(isofile, isobuffer);
if (retval != 0) return(-1); if (retval != 0) return(-1);
if (deviceopencount > 0)
if(deviceopencount > 0) { {
i = 0; i = 0;
while ((i < 2048) && (isocdcheck[i] == isobuffer[i])) i++; while ((i < 2048) && (isocdcheck[i] == isobuffer[i])) i++;
if (i == 2048) deviceopencount = 0; // Same CD/DVD? No delay. if (i == 2048) deviceopencount = 0; // Same CD/DVD? No delay.
} // ENDIF- Is this a restart? Check for disc change. } // ENDIF- Is this a restart? Check for disc change.
for (i = 0; i < 2048; i++) isocdcheck[i] = isobuffer[i]; for (i = 0; i < 2048; i++) isocdcheck[i] = isobuffer[i];
return(0); return(0);
} // END CDVDopen() } // END CDVDopen()
void CALLBACK CDVDclose()
void CALLBACK CDVDclose() { {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDclose()"); PrintLog("CDVDiso interface: CDVDclose()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
@ -194,8 +171,8 @@ void CALLBACK CDVDclose() {
deviceopencount = 50; deviceopencount = 50;
} // END CDVDclose() } // END CDVDclose()
s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq)
s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) { {
char temptime[3]; char temptime[3];
int i; int i;
int pos; int pos;
@ -206,16 +183,17 @@ s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) {
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if (isofile == NULL) return(-1); if (isofile == NULL) return(-1);
if(deviceopencount > 0) { if (deviceopencount > 0)
{
deviceopencount--; deviceopencount--;
if (deviceopencount > 0) return(-1); if (deviceopencount > 0) return(-1);
} // ENDIF- Still simulating device tray open? } // ENDIF- Still simulating device tray open?
if ((isofile->cdvdtype == CDVD_TYPE_PS2DVD) || if ((isofile->cdvdtype == CDVD_TYPE_PS2DVD) ||
(isofile->cdvdtype == CDVD_TYPE_DVDV)) { (isofile->cdvdtype == CDVD_TYPE_DVDV))
{
return(-1); // DVDs don't have SubQ data return(-1); // DVDs don't have SubQ data
} // ENDIF- Trying to get a SubQ from a DVD? } // ENDIF- Trying to get a SubQ from a DVD?
// fake it // fake it
i = BCDTOHEX(isofile->toc[7]); i = BCDTOHEX(isofile->toc[7]);
pos = i * 10; pos = i * 10;
@ -224,7 +202,8 @@ s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) {
temptime[1] = BCDTOHEX(isofile->toc[pos + 8]); temptime[1] = BCDTOHEX(isofile->toc[pos + 8]);
temptime[2] = BCDTOHEX(isofile->toc[pos + 9]); temptime[2] = BCDTOHEX(isofile->toc[pos + 9]);
tracklsn = MSFtoLBA(temptime); tracklsn = MSFtoLBA(temptime);
while((i < BCDTOHEX(isofile->toc[17])) && (tracklsn < lsn)) { while ((i < BCDTOHEX(isofile->toc[17])) && (tracklsn < lsn))
{
i++; i++;
pos = i * 10; pos = i * 10;
pos += 30; pos += 30;
@ -234,7 +213,6 @@ s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) {
tracklsn = MSFtoLBA(temptime); tracklsn = MSFtoLBA(temptime);
} // ENDIF- Loop through tracks searching for lsn track } // ENDIF- Loop through tracks searching for lsn track
i--; i--;
subq->ctrl = 4; subq->ctrl = 4;
subq->mode = 1; subq->mode = 1;
subq->trackNum = HEXTOBCD(i); subq->trackNum = HEXTOBCD(i);
@ -252,37 +230,38 @@ s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) {
subq->discM = HEXTOBCD(temptime[0]); subq->discM = HEXTOBCD(temptime[0]);
subq->discS = HEXTOBCD(temptime[1]); subq->discS = HEXTOBCD(temptime[1]);
subq->discF = HEXTOBCD(temptime[2]); subq->discF = HEXTOBCD(temptime[2]);
return(0); return(0);
} // END CDVDreadSubQ() } // END CDVDreadSubQ()
s32 CALLBACK CDVDgetTN(cdvdTN *Buffer)
s32 CALLBACK CDVDgetTN(cdvdTN *Buffer) { {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDgetTN()"); PrintLog("CDVDiso interface: CDVDgetTN()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if (isofile == NULL) return(-1); if (isofile == NULL) return(-1);
if(deviceopencount > 0) { if (deviceopencount > 0)
{
deviceopencount--; deviceopencount--;
if (deviceopencount > 0) return(-1); if (deviceopencount > 0) return(-1);
} // ENDIF- Still simulating device tray open? } // ENDIF- Still simulating device tray open?
if ((isofile->cdvdtype == CDVD_TYPE_PS2DVD) || if ((isofile->cdvdtype == CDVD_TYPE_PS2DVD) ||
(isofile->cdvdtype == CDVD_TYPE_DVDV)) { (isofile->cdvdtype == CDVD_TYPE_DVDV))
{
Buffer->strack = 1; Buffer->strack = 1;
Buffer->etrack = 1; Buffer->etrack = 1;
} else { }
else
{
Buffer->strack = BCDTOHEX(isofile->toc[7]); Buffer->strack = BCDTOHEX(isofile->toc[7]);
Buffer->etrack = BCDTOHEX(isofile->toc[17]); Buffer->etrack = BCDTOHEX(isofile->toc[17]);
} // ENDIF- Retrieve track info from a DVD? (or a CD?) } // ENDIF- Retrieve track info from a DVD? (or a CD?)
return(0); return(0);
} // END CDVDgetTN() } // END CDVDgetTN()
s32 CALLBACK CDVDgetTD(u8 track, cdvdTD *Buffer)
{
s32 CALLBACK CDVDgetTD(u8 track, cdvdTD *Buffer) {
u8 actualtrack; u8 actualtrack;
int pos; int pos;
char temptime[3]; char temptime[3];
@ -292,31 +271,40 @@ s32 CALLBACK CDVDgetTD(u8 track, cdvdTD *Buffer) {
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if (isofile == NULL) return(-1); if (isofile == NULL) return(-1);
if(deviceopencount > 0) { if (deviceopencount > 0)
{
deviceopencount--; deviceopencount--;
if (deviceopencount > 0) return(-1); if (deviceopencount > 0) return(-1);
} // ENDIF- Still simulating device tray open? } // ENDIF- Still simulating device tray open?
actualtrack = track; actualtrack = track;
if (actualtrack == 0xaa) actualtrack = 0; if (actualtrack == 0xaa) actualtrack = 0;
if ((isofile->cdvdtype == CDVD_TYPE_PS2DVD) || if ((isofile->cdvdtype == CDVD_TYPE_PS2DVD) ||
(isofile->cdvdtype == CDVD_TYPE_DVDV)) { (isofile->cdvdtype == CDVD_TYPE_DVDV))
if (actualtrack <= 1) { {
if (actualtrack <= 1)
{
Buffer->type = 0; Buffer->type = 0;
Buffer->lsn = isofile->filesectorsize; Buffer->lsn = isofile->filesectorsize;
} else { }
else
{
Buffer->type = CDVD_MODE1_TRACK; Buffer->type = CDVD_MODE1_TRACK;
Buffer->lsn = 0; Buffer->lsn = 0;
} // ENDIF- Whole disc? (or single track?) } // ENDIF- Whole disc? (or single track?)
} else { }
if (actualtrack == 0) { else
{
if (actualtrack == 0)
{
Buffer->type = 0; Buffer->type = 0;
temptime[0] = BCDTOHEX(isofile->toc[27]); temptime[0] = BCDTOHEX(isofile->toc[27]);
temptime[1] = BCDTOHEX(isofile->toc[28]); temptime[1] = BCDTOHEX(isofile->toc[28]);
temptime[2] = BCDTOHEX(isofile->toc[29]); temptime[2] = BCDTOHEX(isofile->toc[29]);
Buffer->lsn = MSFtoLBA(temptime); Buffer->lsn = MSFtoLBA(temptime);
} else { }
else
{
pos = actualtrack * 10; pos = actualtrack * 10;
pos += 30; pos += 30;
Buffer->type = isofile->toc[pos]; Buffer->type = isofile->toc[pos];
@ -326,78 +314,72 @@ s32 CALLBACK CDVDgetTD(u8 track, cdvdTD *Buffer) {
Buffer->lsn = MSFtoLBA(temptime); Buffer->lsn = MSFtoLBA(temptime);
} // ENDIF- Whole disc? (or single track?) } // ENDIF- Whole disc? (or single track?)
} // ENDIF- Retrieve track info from a DVD? (or a CD?) } // ENDIF- Retrieve track info from a DVD? (or a CD?)
return(0); return(0);
} // END CDVDgetTD() } // END CDVDgetTD()
s32 CALLBACK CDVDgetTOC(void* toc)
s32 CALLBACK CDVDgetTOC(void* toc) { {
int i; int i;
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDgetTOC()"); PrintLog("CDVDiso interface: CDVDgetTOC()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if (isofile == NULL) return(-1); if (isofile == NULL) return(-1);
if(deviceopencount > 0) { if (deviceopencount > 0)
{
deviceopencount--; deviceopencount--;
if (deviceopencount > 0) return(-1); if (deviceopencount > 0) return(-1);
} // ENDIF- Still simulating device tray open? } // ENDIF- Still simulating device tray open?
for (i = 0; i < 2048; i++) *(((char *) toc) + i) = isofile->toc[i]; for (i = 0; i < 2048; i++) *(((char *) toc) + i) = isofile->toc[i];
return(0); return(0);
} // END CDVDgetTOC() } // END CDVDgetTOC()
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode)
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode) { {
int retval; int retval;
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDreadTrack(%u)", lsn); PrintLog("CDVDiso interface: CDVDreadTrack(%u)", lsn);
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if (isofile == NULL) return(-1); if (isofile == NULL) return(-1);
if(deviceopencount > 0) { if (deviceopencount > 0)
{
deviceopencount--; deviceopencount--;
if (deviceopencount > 0) return(-1); if (deviceopencount > 0) return(-1);
} // ENDIF- Still simulating device tray open? } // ENDIF- Still simulating device tray open?
retval = IsoFileSeek(isofile, (off64_t) lsn); retval = IsoFileSeek(isofile, (off64_t) lsn);
if(retval != 0) { if (retval != 0)
{
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: Trouble finding the sector!"); PrintLog("CDVDiso interface: Trouble finding the sector!");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
return(-1); return(-1);
} // ENDIF- Trouble finding the sector? } // ENDIF- Trouble finding the sector?
retval = IsoFileRead(isofile, isobuffer); retval = IsoFileRead(isofile, isobuffer);
if(retval != 0) { if (retval != 0)
{
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: Trouble reading the sector!"); PrintLog("CDVDiso interface: Trouble reading the sector!");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
return(-1); return(-1);
} // ENDIF- Trouble finding the sector? } // ENDIF- Trouble finding the sector?
isomode = mode; isomode = mode;
return(0); return(0);
} // END CDVDreadTrack() } // END CDVDreadTrack()
u8* CALLBACK CDVDgetBuffer()
u8* CALLBACK CDVDgetBuffer() { {
int offset; int offset;
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDgetBuffer()"); PrintLog("CDVDiso interface: CDVDgetBuffer()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if (isofile == NULL) return(NULL); if (isofile == NULL) return(NULL);
if(deviceopencount > 0) { if (deviceopencount > 0)
{
deviceopencount--; deviceopencount--;
if (deviceopencount > 0) return(NULL); if (deviceopencount > 0) return(NULL);
} // ENDIF- Still simulating device tray open? } // ENDIF- Still simulating device tray open?
offset = 0; offset = 0;
switch(isomode) { switch (isomode)
{
case CDVD_MODE_2352: case CDVD_MODE_2352:
offset = 0; offset = 0;
break; break;
@ -409,44 +391,39 @@ u8* CALLBACK CDVDgetBuffer() {
offset = 24; offset = 24;
break; break;
} // ENDSWITCH isomode- offset to where data it wants is. } // ENDSWITCH isomode- offset to where data it wants is.
if (offset > isofile->blockoffset) offset = isofile->blockoffset; if (offset > isofile->blockoffset) offset = isofile->blockoffset;
return(isobuffer + offset); return(isobuffer + offset);
} // END CDVDgetBuffer() } // END CDVDgetBuffer()
s32 CALLBACK CDVDgetDiskType()
{
s32 CALLBACK CDVDgetDiskType() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
// PrintLog("CDVDiso interface: CDVDgetDiskType()"); // PrintLog("CDVDiso interface: CDVDgetDiskType()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if (isofile == NULL) return(CDVD_TYPE_NODISC); if (isofile == NULL) return(CDVD_TYPE_NODISC);
if(deviceopencount > 0) { if (deviceopencount > 0)
{
deviceopencount--; deviceopencount--;
if (deviceopencount > 0) return(CDVD_TYPE_DETCT); if (deviceopencount > 0) return(CDVD_TYPE_DETCT);
} // ENDIF- Still simulating device tray open? } // ENDIF- Still simulating device tray open?
return(isofile->cdvdtype); return(isofile->cdvdtype);
} // END CDVDgetDiskType() } // END CDVDgetDiskType()
s32 CALLBACK CDVDgetTrayStatus()
{
s32 CALLBACK CDVDgetTrayStatus() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
// PrintLog("CDVDiso interface: CDVDgetTrayStatus()"); // PrintLog("CDVDiso interface: CDVDgetTrayStatus()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if (isofile == NULL) return(CDVD_TRAY_OPEN); if (isofile == NULL) return(CDVD_TRAY_OPEN);
if(deviceopencount > 30) { if (deviceopencount > 30)
{
deviceopencount--; deviceopencount--;
return(CDVD_TRAY_OPEN); return(CDVD_TRAY_OPEN);
} // ENDIF- Still simulating device tray open? } // ENDIF- Still simulating device tray open?
return(CDVD_TRAY_CLOSE); return(CDVD_TRAY_CLOSE);
} // END CDVDgetTrayStatus() } // END CDVDgetTrayStatus()
s32 CALLBACK CDVDctrlTrayOpen()
{
s32 CALLBACK CDVDctrlTrayOpen() {
HWND lastwindow; HWND lastwindow;
int i; int i;
int retval; int retval;
@ -457,12 +434,12 @@ s32 CALLBACK CDVDctrlTrayOpen() {
// CDVDclose(); // CDVDclose();
isofile = IsoFileClose(isofile); isofile = IsoFileClose(isofile);
deviceopencount = 50; deviceopencount = 50;
// CDVDopen(); // CDVDopen();
lastwindow = GetActiveWindow(); lastwindow = GetActiveWindow();
LoadConf(); LoadConf();
if ((conf.isoname[0] == 0) || (conf.isoname[0] == '[') || if ((conf.isoname[0] == 0) || (conf.isoname[0] == '[') ||
((conf.restartconfigure == 1) && (deviceopencount > 0))) { ((conf.restartconfigure == 1) && (deviceopencount > 0)))
{
DialogBox(progmodule, DialogBox(progmodule,
MAKEINTRESOURCE(DLG_0200), MAKEINTRESOURCE(DLG_0200),
lastwindow, lastwindow,
@ -474,9 +451,9 @@ s32 CALLBACK CDVDctrlTrayOpen() {
lastwindow = NULL; lastwindow = NULL;
deviceopencount = 0; // Temp line! deviceopencount = 0; // Temp line!
// NOTE: What happened to repetitive polling when disc not in drive? // NOTE: What happened to repetitive polling when disc not in drive?
isofile = IsoFileOpenForRead(conf.isoname); isofile = IsoFileOpenForRead(conf.isoname);
if(isofile == NULL) { if (isofile == NULL)
{
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: Failed to open ISO file!"); PrintLog("CDVDiso interface: Failed to open ISO file!");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
@ -484,33 +461,29 @@ s32 CALLBACK CDVDctrlTrayOpen() {
for (i = 0; i < 2048; i++) isocdcheck[i] = 0; for (i = 0; i < 2048; i++) isocdcheck[i] = 0;
return(0); return(0);
} // ENDIF- Trouble opening file? Abort. } // ENDIF- Trouble opening file? Abort.
retval = IsoFileSeek(isofile, 16); retval = IsoFileSeek(isofile, 16);
if (retval != 0) return(-1); if (retval != 0) return(-1);
retval = IsoFileRead(isofile, isobuffer); retval = IsoFileRead(isofile, isobuffer);
if (retval != 0) return(-1); if (retval != 0) return(-1);
if (deviceopencount > 0)
if(deviceopencount > 0) { {
i = 0; i = 0;
while ((i < 2048) && (isocdcheck[i] == isobuffer[i])) i++; while ((i < 2048) && (isocdcheck[i] == isobuffer[i])) i++;
if (i == 2048) deviceopencount = 0; // Same CD/DVD? No delay. if (i == 2048) deviceopencount = 0; // Same CD/DVD? No delay.
} // ENDIF- Is this a restart? Check for disc change. } // ENDIF- Is this a restart? Check for disc change.
for (i = 0; i < 2048; i++) isocdcheck[i] = isobuffer[i]; for (i = 0; i < 2048; i++) isocdcheck[i] = isobuffer[i];
return(0); return(0);
} // END CDVDctrlTrayOpen() } // END CDVDctrlTrayOpen()
s32 CALLBACK CDVDctrlTrayClose()
s32 CALLBACK CDVDctrlTrayClose() { {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDctrlTrayClose()"); PrintLog("CDVDiso interface: CDVDctrlTrayClose()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
return(0); return(0);
} // END CDVDctrlTrayClose() } // END CDVDctrlTrayClose()
s32 CALLBACK CDVDtest()
{
s32 CALLBACK CDVDtest() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDiso interface: CDVDtest()"); PrintLog("CDVDiso interface: CDVDtest()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
@ -523,10 +496,9 @@ s32 CALLBACK CDVDtest() {
// Note really need this? Why not just return(0)... // Note really need this? Why not just return(0)...
} // END CDVDtest() } // END CDVDtest()
void CALLBACK CDVDconfigure()
void CALLBACK CDVDconfigure() { {
HWND lastwindow; HWND lastwindow;
lastwindow = GetActiveWindow(); lastwindow = GetActiveWindow();
DialogBox(progmodule, DialogBox(progmodule,
MAKEINTRESOURCE(DLG_0200), MAKEINTRESOURCE(DLG_0200),
@ -536,30 +508,29 @@ void CALLBACK CDVDconfigure() {
lastwindow = NULL; lastwindow = NULL;
return; return;
} // END CDVDconfigure() } // END CDVDconfigure()
BOOL CALLBACK AboutCallback(HWND window, UINT msg, WPARAM param, LPARAM param2)
{
BOOL CALLBACK AboutCallback(HWND window, UINT msg, WPARAM param, LPARAM param2) { switch (msg)
switch(msg) { {
case WM_COMMAND: case WM_COMMAND:
switch(LOWORD(param)) { switch (LOWORD(param))
{
case IDC_0104: // "Ok" Button case IDC_0104: // "Ok" Button
EndDialog(window, FALSE); EndDialog(window, FALSE);
return(TRUE); return(TRUE);
break; break;
} // ENDSWITCH param- Which Windows Message Command? } // ENDSWITCH param- Which Windows Message Command?
case WM_CLOSE: case WM_CLOSE:
EndDialog(window, FALSE); EndDialog(window, FALSE);
return(TRUE); return(TRUE);
break; break;
} // ENDSWITCH msg- what message has been sent to this window? } // ENDSWITCH msg- what message has been sent to this window?
return(FALSE); // Not a recognisable message. Pass it back to the OS. return(FALSE); // Not a recognisable message. Pass it back to the OS.
} // END AboutCallback() } // END AboutCallback()
void CALLBACK CDVDabout() { void CALLBACK CDVDabout()
{
HWND lastwindow; HWND lastwindow;
lastwindow = GetActiveWindow(); lastwindow = GetActiveWindow();
DialogBox(progmodule, DialogBox(progmodule,
MAKEINTRESOURCE(DLG_0100), MAKEINTRESOURCE(DLG_0100),

View File

@ -1,72 +1,31 @@
/* CDVDiso.h /* CDVDiso.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef CDVDISO_H #ifndef CDVDISO_H
#define CDVDISO_H #define CDVDISO_H
#include <windows.h> // HINSTANCE #include <windows.h> // HINSTANCE
// #define VERBOSE_FUNCTION_INTERFACE // #define VERBOSE_FUNCTION_INTERFACE
extern HINSTANCE progmodule; extern HINSTANCE progmodule;
extern char isobuffer[]; extern char isobuffer[];
#endif /* CDVDISO_H */ #endif /* CDVDISO_H */

View File

@ -1,796 +1,412 @@
/* DVD.c /* DVD.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <windows.h> #include <windows.h>
#include <ddk/ntddcdvd.h> // IOCTL_DVD... #include <ddk/ntddcdvd.h> // IOCTL_DVD...
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
#define CDVDdefs #define CDVDdefs
#include "PS2Edefs.h" #include "PS2Edefs.h"
#include "logfile.h" #include "logfile.h"
#include "device.h" // FinishCommand() #include "device.h" // FinishCommand()
struct
{
struct {
DVD_DESCRIPTOR_HEADER h; DVD_DESCRIPTOR_HEADER h;
DVD_LAYER_DESCRIPTOR d; DVD_LAYER_DESCRIPTOR d;
} layer; } layer;
// DVD_LAYER_DESCRIPTOR layer; // DVD_LAYER_DESCRIPTOR layer;
// DVD_COPYRIGHT_DESCRIPTOR copyright; // DVD_COPYRIGHT_DESCRIPTOR copyright;
// DVD_DISK_KEY_DESCRIPTOR disckey; // DVD_DISK_KEY_DESCRIPTOR disckey;
// DVD_BCA_DESCRIPTOR bca; // DVD_BCA_DESCRIPTOR bca;
// DVD_MANUFACTURER_DESCRIPTOR manufact; // DVD_MANUFACTURER_DESCRIPTOR manufact;
void InitDVDInfo()
{
void InitDVDInfo() {
layer.d.EndDataSector = 0; layer.d.EndDataSector = 0;
} // END InitDVDInfo() } // END InitDVDInfo()
s32 DVDGetStructures()
{
s32 DVDGetStructures() {
DVD_SESSION_ID sessionid; DVD_SESSION_ID sessionid;
DVD_READ_STRUCTURE request; DVD_READ_STRUCTURE request;
DWORD byteswritten; DWORD byteswritten;
BOOL boolresult; BOOL boolresult;
DWORD errcode; DWORD errcode;
s32 retval; s32 retval;
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVDiso DVD: DVDgetStructures()"); PrintLog("CDVDiso DVD: DVDgetStructures()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
boolresult = DeviceIoControl(devicehandle, boolresult = DeviceIoControl(devicehandle,
IOCTL_DVD_START_SESSION, IOCTL_DVD_START_SESSION,
NULL, NULL,
0, 0,
&sessionid, &sessionid,
sizeof(DVD_SESSION_ID), sizeof(DVD_SESSION_ID),
&byteswritten, &byteswritten,
&waitevent); &waitevent);
errcode = FinishCommand(boolresult); errcode = FinishCommand(boolresult);
if (errcode != 0)
if(errcode != 0) { {
#ifdef VERBOSE_WARNING_DEVICE #ifdef VERBOSE_WARNING_DEVICE
PrintLog("CDVDiso DVD: Couldn't start session!"); PrintLog("CDVDiso DVD: Couldn't start session!");
PrintError("CDVDiso DVD", errcode); PrintError("CDVDiso DVD", errcode);
#endif /* VERBOSE_WARNING_DEVICE */ #endif /* VERBOSE_WARNING_DEVICE */
return(-1); return(-1);
} // ENDIF- Couldn't start a user session on the DVD drive? Fail. } // ENDIF- Couldn't start a user session on the DVD drive? Fail.
request.BlockByteOffset.QuadPart = 0; request.BlockByteOffset.QuadPart = 0;
request.Format = DvdPhysicalDescriptor; request.Format = DvdPhysicalDescriptor;
request.SessionId = sessionid; request.SessionId = sessionid;
request.LayerNumber = 0; request.LayerNumber = 0;
retval = 0; retval = 0;
boolresult = DeviceIoControl(devicehandle, boolresult = DeviceIoControl(devicehandle,
IOCTL_DVD_READ_STRUCTURE, IOCTL_DVD_READ_STRUCTURE,
&request, &request,
sizeof(DVD_READ_STRUCTURE), sizeof(DVD_READ_STRUCTURE),
&layer, &layer,
sizeof(layer), sizeof(layer),
&byteswritten, &byteswritten,
&waitevent); &waitevent);
errcode = FinishCommand(boolresult); errcode = FinishCommand(boolresult);
if (errcode != 0)
if(errcode != 0) { {
#ifdef VERBOSE_WARNING_DEVICE #ifdef VERBOSE_WARNING_DEVICE
PrintLog("CDVDiso DVD: Couldn't get layer data!"); PrintLog("CDVDiso DVD: Couldn't get layer data!");
PrintError("CDVDiso DVD", errcode); PrintError("CDVDiso DVD", errcode);
#endif /* VERBOSE_WARNING_DEVICE */ #endif /* VERBOSE_WARNING_DEVICE */
retval = -1; retval = -1;
} // ENDIF- Couldn't get layer data? (Including DVD size) Abort. } // ENDIF- Couldn't get layer data? (Including DVD size) Abort.
#ifdef VERBOSE_DISC_INFO #ifdef VERBOSE_DISC_INFO
switch (layer.d.BookType)
switch(layer.d.BookType) { {
case 0: case 0:
PrintLog("CDVDiso DVD: Book Type: DVD-ROM"); PrintLog("CDVDiso DVD: Book Type: DVD-ROM");
break; break;
case 1: case 1:
PrintLog("CDVDiso DVD: Book Type: DVD-RAM"); PrintLog("CDVDiso DVD: Book Type: DVD-RAM");
break; break;
case 2: case 2:
PrintLog("CDVDiso DVD: Book Type: DVD-R"); PrintLog("CDVDiso DVD: Book Type: DVD-R");
break; break;
case 3: case 3:
PrintLog("CDVDiso DVD: Book Type: DVD-RW"); PrintLog("CDVDiso DVD: Book Type: DVD-RW");
break; break;
case 9: case 9:
PrintLog("CDVDiso DVD: Book Type: DVD+RW"); PrintLog("CDVDiso DVD: Book Type: DVD+RW");
break; break;
default: default:
PrintLog("CDVDiso DVD: Book Type: Unknown (%i)", layer.d.BookType); PrintLog("CDVDiso DVD: Book Type: Unknown (%i)", layer.d.BookType);
break; break;
} // ENDSWITCH- Displaying the Book Type } // ENDSWITCH- Displaying the Book Type
PrintLog("CDVDiso DVD: Book Version %i", layer.d.BookVersion); PrintLog("CDVDiso DVD: Book Version %i", layer.d.BookVersion);
switch (layer.d.MinimumRate)
switch(layer.d.MinimumRate) { {
case 0: case 0:
PrintLog("CDVDiso DVD: Use Minimum Rate for: DVD-ROM"); PrintLog("CDVDiso DVD: Use Minimum Rate for: DVD-ROM");
break; break;
case 1: case 1:
PrintLog("CDVDiso DVD: Use Minimum Rate for: DVD-RAM"); PrintLog("CDVDiso DVD: Use Minimum Rate for: DVD-RAM");
break; break;
case 2: case 2:
PrintLog("CDVDiso DVD: Use Minimum Rate for: DVD-R"); PrintLog("CDVDiso DVD: Use Minimum Rate for: DVD-R");
break; break;
case 3: case 3:
PrintLog("CDVDiso DVD: Use Minimum Rate for: DVD-RW"); PrintLog("CDVDiso DVD: Use Minimum Rate for: DVD-RW");
break; break;
case 9: case 9:
PrintLog("CDVDiso DVD: Use Minimum Rate for: DVD+RW"); PrintLog("CDVDiso DVD: Use Minimum Rate for: DVD+RW");
break; break;
default: default:
PrintLog("CDVDiso DVD: Use Minimum Rate for: Unknown (%i)", layer.d.MinimumRate); PrintLog("CDVDiso DVD: Use Minimum Rate for: Unknown (%i)", layer.d.MinimumRate);
break; break;
} // ENDSWITCH- Displaying the Minimum (Spin?) Rate } // ENDSWITCH- Displaying the Minimum (Spin?) Rate
switch (layer.d.DiskSize)
switch(layer.d.DiskSize) { {
case 0: case 0:
PrintLog("CDVDiso DVD: Physical Disk Size: 120mm"); PrintLog("CDVDiso DVD: Physical Disk Size: 120mm");
break; break;
case 1: case 1:
PrintLog("CDVDiso DVD: Physical Disk Size: 80mm"); PrintLog("CDVDiso DVD: Physical Disk Size: 80mm");
break; break;
default: default:
PrintLog("CDVDiso DVD: Physical Disk Size: Unknown (%i)", layer.d.DiskSize); PrintLog("CDVDiso DVD: Physical Disk Size: Unknown (%i)", layer.d.DiskSize);
break; break;
} // ENDSWITCH- What's the Disk Size? } // ENDSWITCH- What's the Disk Size?
switch (layer.d.LayerType)
switch(layer.d.LayerType) { {
case 1: case 1:
PrintLog("CDVDiso DVD: Layer Type: Read-Only"); PrintLog("CDVDiso DVD: Layer Type: Read-Only");
break; break;
case 2: case 2:
PrintLog("CDVDiso DVD: Layer Type: Recordable"); PrintLog("CDVDiso DVD: Layer Type: Recordable");
break; break;
case 4: case 4:
PrintLog("CDVDiso DVD: Layer Type: Rewritable"); PrintLog("CDVDiso DVD: Layer Type: Rewritable");
break; break;
default: default:
PrintLog("CDVDiso DVD: Layer Type: Unknown (%i)", layer.d.LayerType); PrintLog("CDVDiso DVD: Layer Type: Unknown (%i)", layer.d.LayerType);
break; break;
} // ENDSWITCH- Displaying the Layer Type } // ENDSWITCH- Displaying the Layer Type
switch (layer.d.TrackPath)
switch(layer.d.TrackPath) { {
case 0: case 0:
PrintLog("CDVDiso DVD: Track Path: PTP"); PrintLog("CDVDiso DVD: Track Path: PTP");
break; break;
case 1: case 1:
PrintLog("CDVDiso DVD: Track Path: OTP"); PrintLog("CDVDiso DVD: Track Path: OTP");
break; break;
default: default:
PrintLog("CDVDiso DVD: Track Path: Unknown (%i)", layer.d.TrackPath); PrintLog("CDVDiso DVD: Track Path: Unknown (%i)", layer.d.TrackPath);
break; break;
} // ENDSWITCH- What's Track Path Layout? } // ENDSWITCH- What's Track Path Layout?
PrintLog("CDVDiso DVD: Number of Layers: %i", layer.d.NumberOfLayers + 1); PrintLog("CDVDiso DVD: Number of Layers: %i", layer.d.NumberOfLayers + 1);
switch (layer.d.TrackDensity)
switch(layer.d.TrackDensity) { {
case 0: case 0:
PrintLog("CDVDiso DVD: Track Density: .74 m/track"); PrintLog("CDVDiso DVD: Track Density: .74 m/track");
break; break;
case 1: case 1:
PrintLog("CDVDiso DVD: Track Density: .8 m/track"); PrintLog("CDVDiso DVD: Track Density: .8 m/track");
break; break;
case 2: case 2:
PrintLog("CDVDiso DVD: Track Density: .615 m/track"); PrintLog("CDVDiso DVD: Track Density: .615 m/track");
break; break;
default: default:
PrintLog("CDVDiso DVD: Track Density: Unknown (%i)", layer.d.TrackDensity); PrintLog("CDVDiso DVD: Track Density: Unknown (%i)", layer.d.TrackDensity);
break; break;
} // ENDSWITCH- Displaying the Layer Type } // ENDSWITCH- Displaying the Layer Type
switch (layer.d.LinearDensity)
switch(layer.d.LinearDensity) { {
case 0: case 0:
PrintLog("CDVDiso DVD: Linear Density: .267 m/bit"); PrintLog("CDVDiso DVD: Linear Density: .267 m/bit");
break; break;
case 1: case 1:
PrintLog("CDVDiso DVD: Linear Density: .293 m/bit"); PrintLog("CDVDiso DVD: Linear Density: .293 m/bit");
break; break;
case 2: case 2:
PrintLog("CDVDiso DVD: Linear Density: .409 to .435 m/bit"); PrintLog("CDVDiso DVD: Linear Density: .409 to .435 m/bit");
break; break;
case 4: case 4:
PrintLog("CDVDiso DVD: Linear Density: .280 to .291 m/bit"); PrintLog("CDVDiso DVD: Linear Density: .280 to .291 m/bit");
break; break;
case 8: case 8:
PrintLog("CDVDiso DVD: Linear Density: .353 m/bit"); PrintLog("CDVDiso DVD: Linear Density: .353 m/bit");
break; break;
default: default:
PrintLog("CDVDiso DVD: Linear Density: Unknown (%i)", layer.d.LinearDensity); PrintLog("CDVDiso DVD: Linear Density: Unknown (%i)", layer.d.LinearDensity);
break; break;
} // ENDSWITCH- Displaying the Book Type } // ENDSWITCH- Displaying the Book Type
if (layer.d.StartingDataSector == 0x30000)
if(layer.d.StartingDataSector == 0x30000) { {
PrintLog("CDVDiso DVD: Starting Sector: %lu (DVD-ROM, DVD-R, DVD-RW)", PrintLog("CDVDiso DVD: Starting Sector: %lu (DVD-ROM, DVD-R, DVD-RW)",
layer.d.StartingDataSector); layer.d.StartingDataSector);
}
} else if(layer.d.StartingDataSector == 0x31000) { else if (layer.d.StartingDataSector == 0x31000)
{
PrintLog("CDVDiso DVD: Starting Sector: %lu (DVD-RAM, DVD+RW)", PrintLog("CDVDiso DVD: Starting Sector: %lu (DVD-RAM, DVD+RW)",
layer.d.StartingDataSector); layer.d.StartingDataSector);
}
} else { else
{
PrintLog("CDVDiso DVD: Starting Sector: %lu", layer.d.StartingDataSector); PrintLog("CDVDiso DVD: Starting Sector: %lu", layer.d.StartingDataSector);
} // ENDLONGIF- What does the starting sector tell us? } // ENDLONGIF- What does the starting sector tell us?
PrintLog("CDVDiso DVD: End of Layer 0: %lu", layer.d.EndLayerZeroSector); PrintLog("CDVDiso DVD: End of Layer 0: %lu", layer.d.EndLayerZeroSector);
PrintLog("CDVDiso DVD: Ending Sector: %lu", layer.d.EndDataSector); PrintLog("CDVDiso DVD: Ending Sector: %lu", layer.d.EndDataSector);
if (layer.d.BCAFlag != 0) PrintLog("CDVDiso DVD: BCA data present"); if (layer.d.BCAFlag != 0) PrintLog("CDVDiso DVD: BCA data present");
#endif /* VERBOSE_DISC_INFO */ #endif /* VERBOSE_DISC_INFO */
boolresult = DeviceIoControl(devicehandle, boolresult = DeviceIoControl(devicehandle,
IOCTL_DVD_END_SESSION, IOCTL_DVD_END_SESSION,
&sessionid, &sessionid,
sizeof(DVD_SESSION_ID), sizeof(DVD_SESSION_ID),
NULL, NULL,
0, 0,
&byteswritten, &byteswritten,
&waitevent); &waitevent);
errcode = FinishCommand(boolresult); errcode = FinishCommand(boolresult);
if (errcode != 0)
if(errcode != 0) { {
#ifdef VERBOSE_WARNING_DEVICE #ifdef VERBOSE_WARNING_DEVICE
PrintLog("CDVDiso DVD: Couldn't end the session!"); PrintLog("CDVDiso DVD: Couldn't end the session!");
PrintError("CDVDiso DVD", errcode); PrintError("CDVDiso DVD", errcode);
#endif /* VERBOSE_WARNING_DEVICE */ #endif /* VERBOSE_WARNING_DEVICE */
} // ENDIF- Couldn't end the user session? Report it. } // ENDIF- Couldn't end the user session? Report it.
return(retval); return(retval);
} // END DVDGetStructures() } // END DVDGetStructures()
s32 DVDreadTrack(u32 lsn, int mode, u8 *buffer)
{
s32 DVDreadTrack(u32 lsn, int mode, u8 *buffer) {
LARGE_INTEGER targetpos; LARGE_INTEGER targetpos;
DWORD byteswritten; DWORD byteswritten;
BOOL boolresult; BOOL boolresult;
DWORD errcode; DWORD errcode;
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVDiso DVD: DVDreadTrack(%lu)", lsn); PrintLog("CDVDiso DVD: DVDreadTrack(%lu)", lsn);
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
targetpos.QuadPart = lsn * 2048; targetpos.QuadPart = lsn * 2048;
waitevent.Offset = targetpos.LowPart; waitevent.Offset = targetpos.LowPart;
waitevent.OffsetHigh = targetpos.HighPart; waitevent.OffsetHigh = targetpos.HighPart;
boolresult = ReadFile(devicehandle, boolresult = ReadFile(devicehandle,
buffer, buffer,
2048, 2048,
&byteswritten, &byteswritten,
&waitevent); &waitevent);
errcode = FinishCommand(boolresult); errcode = FinishCommand(boolresult);
if (errcode != 0)
{
if(errcode != 0) {
#ifdef VERBOSE_WARNING_DEVICE #ifdef VERBOSE_WARNING_DEVICE
PrintLog("CDVDiso DVD: Couldn't read sector!"); PrintLog("CDVDiso DVD: Couldn't read sector!");
PrintError("CDVDiso DVD", errcode); PrintError("CDVDiso DVD", errcode);
#endif /* VERBOSE_WARNING_DEVICE */ #endif /* VERBOSE_WARNING_DEVICE */
return(-1); return(-1);
} // ENDIF- Trouble with the command? Report it. } // ENDIF- Trouble with the command? Report it.
if (boolresult == FALSE)
{
if(boolresult == FALSE) {
boolresult = GetOverlappedResult(devicehandle, boolresult = GetOverlappedResult(devicehandle,
&waitevent, &waitevent,
&byteswritten, &byteswritten,
FALSE); FALSE);
} // ENDIF- Did the initial call not complete? Get byteswritten for } // ENDIF- Did the initial call not complete? Get byteswritten for
// the completed call. // the completed call.
if (byteswritten < 2048)
{
if(byteswritten < 2048) {
#ifdef VERBOSE_WARNING_DEVICE #ifdef VERBOSE_WARNING_DEVICE
errcode = GetLastError(); errcode = GetLastError();
PrintLog("CDVDiso CD: Short block! only got %u out of %u bytes", PrintLog("CDVDiso CD: Short block! only got %u out of %u bytes",
byteswritten, 2048); byteswritten, 2048);
PrintError("CDVDiso CD", errcode); PrintError("CDVDiso CD", errcode);
#endif /* VERBOSE_WARNING_DEVICE */ #endif /* VERBOSE_WARNING_DEVICE */
return(-1); return(-1);
} // ENDIF- Didn't get enough bytes? Report and Abort! } // ENDIF- Didn't get enough bytes? Report and Abort!
return(0); return(0);
} // END DVDreadTrack() } // END DVDreadTrack()
s32 DVDgetTN(cdvdTN *cdvdtn)
{
s32 DVDgetTN(cdvdTN *cdvdtn) {
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVDiso DVD: DVDgetTN()"); PrintLog("CDVDiso DVD: DVDgetTN()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
if (cdvdtn != NULL)
{
if(cdvdtn != NULL) {
cdvdtn->strack = 1; cdvdtn->strack = 1;
cdvdtn->etrack = 1; cdvdtn->etrack = 1;
} // ENDIF- Does the user really want this data? } // ENDIF- Does the user really want this data?
return(0); return(0);
} // END DVDgetTN() } // END DVDgetTN()
s32 DVDgetTD(u8 newtrack, cdvdTD *cdvdtd)
{
s32 DVDgetTD(u8 newtrack, cdvdTD *cdvdtd) {
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVDiso DVD: DVDgetTD()"); PrintLog("CDVDiso DVD: DVDgetTD()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
if ((newtrack >= 2) && (newtrack != 0xAA)) return(-1); // Wrong track if ((newtrack >= 2) && (newtrack != 0xAA)) return(-1); // Wrong track
if (cdvdtd != NULL)
{
if(cdvdtd != NULL) {
cdvdtd->type = 0; cdvdtd->type = 0;
cdvdtd->lsn = layer.d.EndDataSector - layer.d.StartingDataSector + 1; cdvdtd->lsn = layer.d.EndDataSector - layer.d.StartingDataSector + 1;
} // ENDIF- Does the user really want this data? } // ENDIF- Does the user really want this data?
return(0); return(0);
} // END DVDgetTD() } // END DVDgetTD()
s32 DVDgetDiskType()
{
s32 DVDgetDiskType() {
char playstationname[] = "PLAYSTATION\0"; char playstationname[] = "PLAYSTATION\0";
int retval; int retval;
s32 tempdisctype; s32 tempdisctype;
char tempbuffer[2048]; char tempbuffer[2048];
int i; int i;
#ifdef VERBOSE_FUNCTION_DEVICE #ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVDiso DVD: DVDgetDiskType()"); PrintLog("CDVDiso DVD: DVDgetDiskType()");
#endif /* VERBOSE_FUNCTION_DEVICE */ #endif /* VERBOSE_FUNCTION_DEVICE */
retval = DVDGetStructures(); retval = DVDGetStructures();
if (retval < 0) return(-1); // Can't get DVD structures? Not a DVD then. if (retval < 0) return(-1); // Can't get DVD structures? Not a DVD then.
if (layer.d.EndDataSector == 0) return(-1); // Missing info? Abort. if (layer.d.EndDataSector == 0) return(-1); // Missing info? Abort.
retval = DVDreadTrack(16, CDVD_MODE_2048, tempbuffer); retval = DVDreadTrack(16, CDVD_MODE_2048, tempbuffer);
if (retval < 0)
if(retval < 0) { {
return(-1); return(-1);
} // ENDIF- Couldn't read the ISO9660 volume track? Fail. } // ENDIF- Couldn't read the ISO9660 volume track? Fail.
tempdisctype = CDVD_TYPE_UNKNOWN; tempdisctype = CDVD_TYPE_UNKNOWN;
if (layer.d.NumberOfLayers == 0)
if(layer.d.NumberOfLayers == 0) { {
#ifdef VERBOSE_DISC_INFO #ifdef VERBOSE_DISC_INFO
PrintLog("CDVDiso DVD: Found Single-Sided DVD."); PrintLog("CDVDiso DVD: Found Single-Sided DVD.");
#endif /* VERBOSE_DISC_INFO */ #endif /* VERBOSE_DISC_INFO */
disctype = CDVD_TYPE_DETCTDVDS; disctype = CDVD_TYPE_DETCTDVDS;
}
} else { else
{
#ifdef VERBOSE_DISC_INFO #ifdef VERBOSE_DISC_INFO
PrintLog("CDVDiso DVD: Found Dual-Sided DVD."); PrintLog("CDVDiso DVD: Found Dual-Sided DVD.");
#endif /* VERBOSE_DISC_INFO */ #endif /* VERBOSE_DISC_INFO */
disctype = CDVD_TYPE_DETCTDVDD; disctype = CDVD_TYPE_DETCTDVDD;
} // ENDIF- Are we looking at a single layer DVD? (NumberOfLayers + 1) } // ENDIF- Are we looking at a single layer DVD? (NumberOfLayers + 1)
i = 0; i = 0;
while ((playstationname[i] != 0) && while ((playstationname[i] != 0) &&
(playstationname[i] == tempbuffer[8 + i])) i++; (playstationname[i] == tempbuffer[8 + i])) i++;
if (playstationname[i] == 0)
if(playstationname[i] == 0) { {
#ifdef VERBOSE_DISC_TYPE #ifdef VERBOSE_DISC_TYPE
PrintLog("CDVDiso DVD: Found Playstation 2 DVD."); PrintLog("CDVDiso DVD: Found Playstation 2 DVD.");
#endif /* VERBOSE_DISC_TYPE */ #endif /* VERBOSE_DISC_TYPE */
tempdisctype = CDVD_TYPE_PS2DVD; tempdisctype = CDVD_TYPE_PS2DVD;
}
} else { else
{
#ifdef VERBOSE_DISC_TYPE #ifdef VERBOSE_DISC_TYPE
PrintLog("CDVDiso DVD: Guessing it's a Video DVD."); PrintLog("CDVDiso DVD: Guessing it's a Video DVD.");
#endif /* VERBOSE_DISC_TYPE */ #endif /* VERBOSE_DISC_TYPE */
tempdisctype = CDVD_TYPE_DVDV; tempdisctype = CDVD_TYPE_DVDV;
} // ENDIF- Is this a playstation disc? } // ENDIF- Is this a playstation disc?
for (i = 0; i < 2048; i++) tocbuffer[i] = 0; for (i = 0; i < 2048; i++) tocbuffer[i] = 0;
if (layer.d.NumberOfLayers == 0)
{
if(layer.d.NumberOfLayers == 0) {
tocbuffer[0] = 0x04; tocbuffer[0] = 0x04;
tocbuffer[4] = 0x86; tocbuffer[4] = 0x86;
tocbuffer[5] = 0x72; tocbuffer[5] = 0x72;
}
} else { else
{
tocbuffer[0] = 0x24; tocbuffer[0] = 0x24;
tocbuffer[4] = 0x41; tocbuffer[4] = 0x41;
tocbuffer[5] = 0x95; tocbuffer[5] = 0x95;
} // ENDIF- Are we looking at a single layer DVD? (NumberOfLayers + 1) } // ENDIF- Are we looking at a single layer DVD? (NumberOfLayers + 1)
tocbuffer[1] = 0x02; tocbuffer[1] = 0x02;
tocbuffer[2] = 0xF2; tocbuffer[2] = 0xF2;
tocbuffer[3] = 0x00; tocbuffer[3] = 0x00;
tocbuffer[16] = 0x00; tocbuffer[16] = 0x00;
tocbuffer[17] = 0x03; tocbuffer[17] = 0x03;
tocbuffer[18] = 0x00; tocbuffer[18] = 0x00;
tocbuffer[19] = 0x00; tocbuffer[19] = 0x00;
disctype = tempdisctype; disctype = tempdisctype;
return(disctype); return(disctype);
} // END DVDgetDiskType() } // END DVDgetDiskType()

View File

@ -1,74 +1,33 @@
/* DVD.h /* DVD.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef DVD_H #ifndef DVD_H
#define DVD_H #define DVD_H
#define CDVDdefs #define CDVDdefs
#include "PS2Edefs.h" #include "PS2Edefs.h"
extern void InitDVDInfo(); extern void InitDVDInfo();
extern s32 DVDreadTrack(u32 lsn, int mode, u8 *buffer); extern s32 DVDreadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 DVDgetTN(cdvdTN *cdvdtn); extern s32 DVDgetTN(cdvdTN *cdvdtn);
extern s32 DVDgetTD(u8 newtrack, cdvdTD *cdvdtd); extern s32 DVDgetTD(u8 newtrack, cdvdTD *cdvdtd);
extern s32 DVDgetDiskType(); extern s32 DVDgetDiskType();
#endif /* DVD_H */ #endif /* DVD_H */

View File

@ -1,506 +1,233 @@
/* actualfile.c /* actualfile.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <windows.h> #include <windows.h>
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include "logfile.h" #include "logfile.h"
#include "actualfile.h" #include "actualfile.h"
int IsActualFile(const char *filename)
{
int IsActualFile(const char *filename) {
DWORD retval; DWORD retval;
if (filename == NULL) return(-1); if (filename == NULL) return(-1);
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: IsActualFile(%s)", filename); PrintLog("CDVDiso file: IsActualFile(%s)", filename);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
retval = GetFileAttributes(filename); retval = GetFileAttributes(filename);
if (retval == INVALID_FILE_ATTRIBUTES) return(-1); // Name doesn't exist. if (retval == INVALID_FILE_ATTRIBUTES) return(-1); // Name doesn't exist.
if ((retval & FILE_ATTRIBUTE_DIRECTORY) != 0) return(-2); if ((retval & FILE_ATTRIBUTE_DIRECTORY) != 0) return(-2);
return(0); // Yep, that's a file. return(0); // Yep, that's a file.
} // END IsActualFile() } // END IsActualFile()
void ActualFileDelete(const char *filename)
{
void ActualFileDelete(const char *filename) {
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileDelete(%s)", filename); PrintLog("CDVDiso file: ActualFileDelete(%s)", filename);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
DeleteFile(filename); DeleteFile(filename);
} // END ActualFileDelete() } // END ActualFileDelete()
void ActualFileRename(const char *origname, const char *newname)
{
void ActualFileRename(const char *origname, const char *newname) {
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileDelete(%s->%s)", origname, newname); PrintLog("CDVDiso file: ActualFileDelete(%s->%s)", origname, newname);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
MoveFile(origname, newname); MoveFile(origname, newname);
return; return;
} // END ActualFileRename() } // END ActualFileRename()
ACTUALHANDLE ActualFileOpenForRead(const char *filename)
{
ACTUALHANDLE ActualFileOpenForRead(const char *filename) {
HANDLE newhandle; HANDLE newhandle;
if (filename == NULL) return(NULL); if (filename == NULL) return(NULL);
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileOpenForRead(%s)", filename); PrintLog("CDVDiso file: ActualFileOpenForRead(%s)", filename);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
newhandle = CreateFile(filename, newhandle = CreateFile(filename,
GENERIC_READ, GENERIC_READ,
FILE_SHARE_READ, FILE_SHARE_READ,
NULL, NULL,
OPEN_EXISTING, OPEN_EXISTING,
FILE_FLAG_RANDOM_ACCESS, FILE_FLAG_RANDOM_ACCESS,
NULL); NULL);
if (newhandle == INVALID_HANDLE_VALUE)
if(newhandle == INVALID_HANDLE_VALUE) { {
#ifdef VERBOSE_WARNING_ACTUALFILE #ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Error opening file %s", filename); PrintLog("CDVDiso file: Error opening file %s", filename);
#endif /* VERBOSE_WARNING_ACTUALFILE */ #endif /* VERBOSE_WARNING_ACTUALFILE */
return(NULL); return(NULL);
} // ENDIF- Error? Abort } // ENDIF- Error? Abort
return(newhandle); return(newhandle);
} // END ActualFileOpenForRead() } // END ActualFileOpenForRead()
off64_t ActualFileSize(ACTUALHANDLE handle)
{
off64_t ActualFileSize(ACTUALHANDLE handle) {
int retval; int retval;
BY_HANDLE_FILE_INFORMATION info; BY_HANDLE_FILE_INFORMATION info;
off64_t retsize; off64_t retsize;
if (handle == NULL) return(-1); if (handle == NULL) return(-1);
if (handle == INVALID_HANDLE_VALUE) return(-1); if (handle == INVALID_HANDLE_VALUE) return(-1);
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileSize()"); PrintLog("CDVDiso file: ActualFileSize()");
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
retval = GetFileInformationByHandle(handle, &info); retval = GetFileInformationByHandle(handle, &info);
if (retval == 0) return(-1); // Handle doesn't exist... if (retval == 0) return(-1); // Handle doesn't exist...
retsize = info.nFileSizeHigh; retsize = info.nFileSizeHigh;
retsize *= 0x10000; retsize *= 0x10000;
retsize *= 0x10000; retsize *= 0x10000;
retsize += info.nFileSizeLow; retsize += info.nFileSizeLow;
return(retsize); return(retsize);
} // END ActualFileSize() } // END ActualFileSize()
int ActualFileSeek(ACTUALHANDLE handle, off64_t position)
{
int ActualFileSeek(ACTUALHANDLE handle, off64_t position) {
// int retval; // int retval;
LARGE_INTEGER realpos; LARGE_INTEGER realpos;
DWORD errcode; DWORD errcode;
if (handle == NULL) return(-1); if (handle == NULL) return(-1);
if (handle == INVALID_HANDLE_VALUE) return(-1); if (handle == INVALID_HANDLE_VALUE) return(-1);
if (position < 0) return(-1); if (position < 0) return(-1);
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileSeek(%llu)", position); PrintLog("CDVDiso file: ActualFileSeek(%llu)", position);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
realpos.QuadPart = position; realpos.QuadPart = position;
////// WinXP code for seek ////// WinXP code for seek
// retval = SetFilePointerEx(handle, // retval = SetFilePointerEx(handle,
// realpos, // realpos,
// NULL, // NULL,
// FILE_BEGIN); // FILE_BEGIN);
// if(retval == 0) { // if(retval == 0) {
////// Win98 code for seek ////// Win98 code for seek
realpos.LowPart = SetFilePointer(handle, realpos.LowPart = SetFilePointer(handle,
realpos.LowPart, realpos.LowPart,
&realpos.HighPart, &realpos.HighPart,
FILE_BEGIN); FILE_BEGIN);
errcode = GetLastError(); errcode = GetLastError();
if ((realpos.LowPart == 0xFFFFFFFF) && (errcode != NO_ERROR))
if((realpos.LowPart == 0xFFFFFFFF) && (errcode != NO_ERROR)) { {
#ifdef VERBOSE_WARNING_ACTUALFILE #ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Error on seek (%llu)", position); PrintLog("CDVDiso file: Error on seek (%llu)", position);
PrintError("CDVDiso file", errcode); PrintError("CDVDiso file", errcode);
#endif /* VERBOSE_WARNING_ACTUALFILE */ #endif /* VERBOSE_WARNING_ACTUALFILE */
return(-1); return(-1);
} // ENDIF- Error? Abort } // ENDIF- Error? Abort
return(0); return(0);
} // END ActualFileSeek() } // END ActualFileSeek()
int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer)
{
int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer) {
int retval; int retval;
DWORD bytesread; DWORD bytesread;
#ifdef VERBOSE_WARNING_ACTUALFILE #ifdef VERBOSE_WARNING_ACTUALFILE
DWORD errcode; DWORD errcode;
#endif /* VERBOSE_WARNING_ACTUALFILE */ #endif /* VERBOSE_WARNING_ACTUALFILE */
if (handle == NULL) return(-1); if (handle == NULL) return(-1);
if (handle == INVALID_HANDLE_VALUE) return(-1); if (handle == INVALID_HANDLE_VALUE) return(-1);
if (bytes < 1) return(-1); if (bytes < 1) return(-1);
if (buffer == NULL) return(-1); if (buffer == NULL) return(-1);
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileRead(%i)", bytes); PrintLog("CDVDiso file: ActualFileRead(%i)", bytes);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
retval = ReadFile(handle, buffer, bytes, &bytesread, NULL); retval = ReadFile(handle, buffer, bytes, &bytesread, NULL);
if (retval == 0)
if(retval == 0) { {
#ifdef VERBOSE_WARNING_ACTUALFILE #ifdef VERBOSE_WARNING_ACTUALFILE
errcode = GetLastError(); errcode = GetLastError();
PrintLog("CDVDiso file: Error reading from file"); PrintLog("CDVDiso file: Error reading from file");
PrintError("CDVDiso file", errcode); PrintError("CDVDiso file", errcode);
#endif /* VERBOSE_WARNING_ACTUALFILE */ #endif /* VERBOSE_WARNING_ACTUALFILE */
return(-1); return(-1);
} // ENDIF- Error? Abort } // ENDIF- Error? Abort
if (bytesread < bytes)
if(bytesread < bytes) { {
#ifdef VERBOSE_WARNING_ACTUALFILE #ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Short Block! Only read %i out of %i bytes", bytesread, bytes); PrintLog("CDVDiso file: Short Block! Only read %i out of %i bytes", bytesread, bytes);
#endif /* VERBOSE_WARNING_ACTUALFILE */ #endif /* VERBOSE_WARNING_ACTUALFILE */
} // ENDIF- Error? Abort } // ENDIF- Error? Abort
return(bytesread); // Send back how many bytes read return(bytesread); // Send back how many bytes read
} // END ActualFileRead() } // END ActualFileRead()
void ActualFileClose(ACTUALHANDLE handle)
{
void ActualFileClose(ACTUALHANDLE handle) {
if (handle == NULL) return; if (handle == NULL) return;
if (handle == INVALID_HANDLE_VALUE) return; if (handle == INVALID_HANDLE_VALUE) return;
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileClose()"); PrintLog("CDVDiso file: ActualFileClose()");
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
CloseHandle(handle); CloseHandle(handle);
return; return;
} // END ActualFileClose() } // END ActualFileClose()
ACTUALHANDLE ActualFileOpenForWrite(const char *filename)
{
ACTUALHANDLE ActualFileOpenForWrite(const char *filename) {
HANDLE newhandle; HANDLE newhandle;
if (filename == NULL) return(NULL); if (filename == NULL) return(NULL);
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileOpenForWrite(%s)", filename); PrintLog("CDVDiso file: ActualFileOpenForWrite(%s)", filename);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
newhandle = CreateFile(filename, newhandle = CreateFile(filename,
GENERIC_WRITE, GENERIC_WRITE,
0, 0,
NULL, NULL,
CREATE_ALWAYS, CREATE_ALWAYS,
FILE_FLAG_SEQUENTIAL_SCAN, FILE_FLAG_SEQUENTIAL_SCAN,
NULL); NULL);
if (newhandle == INVALID_HANDLE_VALUE)
if(newhandle == INVALID_HANDLE_VALUE) { {
#ifdef VERBOSE_WARNING_ACTUALFILE #ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Error opening file %s", filename); PrintLog("CDVDiso file: Error opening file %s", filename);
#endif /* VERBOSE_WARNING_ACTUALFILE */ #endif /* VERBOSE_WARNING_ACTUALFILE */
return(NULL); return(NULL);
} // ENDIF- Error? Abort } // ENDIF- Error? Abort
return(newhandle); return(newhandle);
} // END ActualFileOpenForWrite() } // END ActualFileOpenForWrite()
int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer)
{
int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer) {
int retval; int retval;
DWORD byteswritten; DWORD byteswritten;
if (handle == NULL) return(-1); if (handle == NULL) return(-1);
if (handle == INVALID_HANDLE_VALUE) return(-1); if (handle == INVALID_HANDLE_VALUE) return(-1);
if (bytes < 1) return(-1); if (bytes < 1) return(-1);
if (buffer == NULL) return(-1); if (buffer == NULL) return(-1);
#ifdef VERBOSE_FUNCTION_ACTUALFILE #ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileWrite(%i)", bytes); PrintLog("CDVDiso file: ActualFileWrite(%i)", bytes);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */ #endif /* VERBOSE_FUNCTION_ACTUALFILE */
retval = WriteFile(handle, buffer, bytes, &byteswritten, NULL); retval = WriteFile(handle, buffer, bytes, &byteswritten, NULL);
if (retval == 0)
if(retval == 0) { {
#ifdef VERBOSE_WARNING_ACTUALFILE #ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Error writing to file!"); PrintLog("CDVDiso file: Error writing to file!");
#endif /* VERBOSE_WARNING_ACTUALFILE */ #endif /* VERBOSE_WARNING_ACTUALFILE */
// return(-1); // return(-1);
} // ENDIF- Error? Abort } // ENDIF- Error? Abort
return(byteswritten); // Send back how many bytes written return(byteswritten); // Send back how many bytes written
} // END ActualFileWrite() } // END ActualFileWrite()

View File

@ -1,104 +1,45 @@
/* actualfile.h /* actualfile.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef ACTUALFILE_H #ifndef ACTUALFILE_H
#define ACTUALFILE_H #define ACTUALFILE_H
#include <windows.h> #include <windows.h>
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
#include "PS2Etypes.h" #include "PS2Etypes.h"
#define ACTUALHANDLE HANDLE #define ACTUALHANDLE HANDLE
#define ACTUALHANDLENULL NULL #define ACTUALHANDLENULL NULL
// #define VERBOSE_FUNCTION_ACTUALFILE // #define VERBOSE_FUNCTION_ACTUALFILE
// #define VERBOSE_WARNING_ACTUALFILE // #define VERBOSE_WARNING_ACTUALFILE
extern int IsActualFile(const char *filename); extern int IsActualFile(const char *filename);
extern void ActualFileDelete(const char *filename); extern void ActualFileDelete(const char *filename);
extern void ActualFileRename(const char *origname, const char *newname); extern void ActualFileRename(const char *origname, const char *newname);
extern ACTUALHANDLE ActualFileOpenForRead(const char *filename); extern ACTUALHANDLE ActualFileOpenForRead(const char *filename);
extern off64_t ActualFileSize(ACTUALHANDLE handle); extern off64_t ActualFileSize(ACTUALHANDLE handle);
extern int ActualFileSeek(ACTUALHANDLE handle, off64_t position); extern int ActualFileSeek(ACTUALHANDLE handle, off64_t position);
extern int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer); extern int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer);
extern void ActualFileClose(ACTUALHANDLE handle); extern void ActualFileClose(ACTUALHANDLE handle);
extern ACTUALHANDLE ActualFileOpenForWrite(const char *filename); extern ACTUALHANDLE ActualFileOpenForWrite(const char *filename);
extern int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer); extern int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer);
#endif /* ACTUALFILE_H */ #endif /* ACTUALFILE_H */

View File

@ -1,390 +1,217 @@
/* conf.c /* conf.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <errno.h> // errno #include <errno.h> // errno
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <stdlib.h> // getenv() #include <stdlib.h> // getenv()
#include <string.h> // strerror() #include <string.h> // strerror()
#include <sys/stat.h> // mkdir(), stat() #include <sys/stat.h> // mkdir(), stat()
#include <sys/types.h> // mkdir(), stat(), fork() #include <sys/types.h> // mkdir(), stat(), fork()
#include <unistd.h> // stat(), fork(), execlp() #include <unistd.h> // stat(), fork(), execlp()
#include <windows.h> // CreateProcess() #include <windows.h> // CreateProcess()
// #define CDVDdefs // #define CDVDdefs
// #include "../PS2Edefs.h" // #include "../PS2Edefs.h"
#include "../PS2Etypes.h" // u8 #include "../PS2Etypes.h" // u8
#include "logfile.h" #include "logfile.h"
#include "../ini.h" #include "../ini.h"
#include "conf.h" #include "conf.h"
const char *confnames[] = { "IsoFile", "Device", "OpenOnStart", "OpenOnRestart", NULL }; const char *confnames[] = { "IsoFile", "Device", "OpenOnStart", "OpenOnRestart", NULL };
const u8 defaultdevice[] = DEFAULT_DEVICE; const u8 defaultdevice[] = DEFAULT_DEVICE;
const char defaulthome[] = "inis"; const char defaulthome[] = "inis";
const char defaultdirectory[] = "HideMe.PS2E"; const char defaultdirectory[] = "HideMe.PS2E";
const char defaultfile[] = "CDVDisoEFP.ini"; const char defaultfile[] = "CDVDisoEFP.ini";
char confdirname[256]; char confdirname[256];
char conffilename[256]; char conffilename[256];
CDVDconf conf; CDVDconf conf;
void InitConf()
{
void InitConf() {
DWORD retval; DWORD retval;
int i; int i;
int pos; int pos;
char *envptr; char *envptr;
#ifdef VERBOSE_FUNCTION_CONF #ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: InitConf()"); PrintLog("CDVD config: InitConf()");
#endif /* VERBOSE_FUNCTION_CONF */ #endif /* VERBOSE_FUNCTION_CONF */
conf.isoname[0] = 0; // Empty the iso name conf.isoname[0] = 0; // Empty the iso name
i = 0; i = 0;
while ((i < 255) && defaultdevice[i] != 0)
while((i < 255) && defaultdevice[i] != 0) { {
conf.devicename[i] = defaultdevice[i]; conf.devicename[i] = defaultdevice[i];
i++; i++;
} // ENDWHILE- copying the default CD/DVD name in } // ENDWHILE- copying the default CD/DVD name in
conf.devicename[i] = 0; // 0-terminate the device name conf.devicename[i] = 0; // 0-terminate the device name
// Locating directory and file positions // Locating directory and file positions
pos = 0; pos = 0;
envptr = NULL; envptr = NULL;
// envptr = getenv("HOME"); // envptr = getenv("HOME");
if (envptr == NULL)
if(envptr == NULL) { {
// = <Default Home> // = <Default Home>
retval = GetCurrentDirectory(253, confdirname); retval = GetCurrentDirectory(253, confdirname);
if (retval > 0)
if(retval > 0) { {
pos = retval; pos = retval;
}
} else { else
{
pos = 2; pos = 2;
confdirname[0] = '.'; confdirname[0] = '.';
confdirname[1] = '\\'; confdirname[1] = '\\';
} // ENDIF- Did we retrieve a directory reference? } // ENDIF- Did we retrieve a directory reference?
i = 0; i = 0;
while (i < pos)
while(i < pos) { {
conffilename[i] = confdirname[i]; conffilename[i] = confdirname[i];
i++; i++;
} // ENDWHILE- Copying dir info (so far) into file info } // ENDWHILE- Copying dir info (so far) into file info
if (confdirname[pos-1] != '\\')
{
if(confdirname[pos-1] != '\\') {
confdirname[pos] = '\\'; confdirname[pos] = '\\';
conffilename[pos] = '\\'; conffilename[pos] = '\\';
pos++; pos++;
} // ENDIF- No directory separator here? Add one. } // ENDIF- No directory separator here? Add one.
i = 0; i = 0;
while ((pos < 253) && (defaulthome[i] != 0))
while((pos < 253) && (defaulthome[i] != 0)) { {
confdirname[pos] = defaulthome[i]; confdirname[pos] = defaulthome[i];
conffilename[pos] = defaulthome[i]; conffilename[pos] = defaulthome[i];
pos++; pos++;
i++; i++;
} // ENDWHILE- putting an offset where to store ini data } // ENDWHILE- putting an offset where to store ini data
}
else
} else { {
// = <Env Home>/<Default Directory> // = <Env Home>/<Default Directory>
i = 0; i = 0;
while ((pos < 253) && (*(envptr + i) != 0))
while((pos < 253) && (*(envptr + i) != 0)) { {
confdirname[pos] = *(envptr + i); confdirname[pos] = *(envptr + i);
conffilename[pos] = *(envptr + i); conffilename[pos] = *(envptr + i);
pos++; pos++;
i++; i++;
} // ENDWHILE- copying home directory info in } // ENDWHILE- copying home directory info in
if (confdirname[pos-1] != '\\')
{
if(confdirname[pos-1] != '\\') {
confdirname[pos] = '\\'; confdirname[pos] = '\\';
conffilename[pos] = '\\'; conffilename[pos] = '\\';
pos++; pos++;
} // ENDIF- No directory separator here? Add one. } // ENDIF- No directory separator here? Add one.
i = 0; i = 0;
while ((pos < 253) && (defaultdirectory[i] != 0))
while((pos < 253) && (defaultdirectory[i] != 0)) { {
confdirname[pos] = defaultdirectory[i]; confdirname[pos] = defaultdirectory[i];
conffilename[pos] = defaultdirectory[i]; conffilename[pos] = defaultdirectory[i];
pos++; pos++;
i++; i++;
} // NEXT- putting a default place to store configuration data } // NEXT- putting a default place to store configuration data
} // ENDIF- No Home directory? } // ENDIF- No Home directory?
confdirname[pos] = 0; // Directory reference finished confdirname[pos] = 0; // Directory reference finished
// += /<Config File Name> // += /<Config File Name>
if (conffilename[pos-1] != '\\')
if(conffilename[pos-1] != '\\') { {
conffilename[pos] = '\\'; conffilename[pos] = '\\';
pos++; pos++;
} // ENDIF- No directory separator here? Add one. } // ENDIF- No directory separator here? Add one.
i = 0; i = 0;
while ((pos < 253) && (defaultfile[i] != 0))
while((pos < 253) && (defaultfile[i] != 0)) { {
conffilename[pos] = defaultfile[i]; conffilename[pos] = defaultfile[i];
pos++; pos++;
i++; i++;
} // NEXT- putting a default place to store configuration data } // NEXT- putting a default place to store configuration data
conffilename[pos] = 0; // File reference finished conffilename[pos] = 0; // File reference finished
#ifdef VERBOSE_FUNCTION_CONF #ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: Directory: %s", confdirname); PrintLog("CDVD config: Directory: %s", confdirname);
PrintLog("CDVD config: File: %s", conffilename); PrintLog("CDVD config: File: %s", conffilename);
#endif /* VERBOSE_FUNCTION_CONF */ #endif /* VERBOSE_FUNCTION_CONF */
} // END InitConf() } // END InitConf()
void LoadConf()
{
void LoadConf() {
int retval; int retval;
#ifdef VERBOSE_FUNCTION_CONF #ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: LoadConf()"); PrintLog("CDVD config: LoadConf()");
#endif /* VERBOSE_FUNCTION_CONF */ #endif /* VERBOSE_FUNCTION_CONF */
retval = INILoadString(conffilename, "Settings", "IsoFile", conf.isoname); retval = INILoadString(conffilename, "Settings", "IsoFile", conf.isoname);
if (retval < 0)
if(retval < 0) { {
sprintf(conf.isoname, "[Put an Image File here]"); sprintf(conf.isoname, "[Put an Image File here]");
} // ENDIF- Couldn't find keyword? Fill in a default } // ENDIF- Couldn't find keyword? Fill in a default
retval = INILoadString(conffilename, "Settings", "Device", conf.devicename); retval = INILoadString(conffilename, "Settings", "Device", conf.devicename);
if (retval < 0)
if(retval < 0) { {
sprintf(conf.devicename, "D:"); sprintf(conf.devicename, "D:");
} // ENDIF- Couldn't find keyword? Fill in a default } // ENDIF- Couldn't find keyword? Fill in a default
retval = INILoadUInt(conffilename, "Settings", "OpenOnStart", &conf.startconfigure); retval = INILoadUInt(conffilename, "Settings", "OpenOnStart", &conf.startconfigure);
if (retval < 0)
if(retval < 0) { {
conf.startconfigure = 0; // FALSE conf.startconfigure = 0; // FALSE
} // ENDIF- Couldn't find keyword? Fill in a default } // ENDIF- Couldn't find keyword? Fill in a default
retval = INILoadUInt(conffilename, "Settings", "OpenOnRestart", &conf.restartconfigure); retval = INILoadUInt(conffilename, "Settings", "OpenOnRestart", &conf.restartconfigure);
if (retval < 0)
if(retval < 0) { {
conf.restartconfigure = 1; // TRUE conf.restartconfigure = 1; // TRUE
} // ENDIF- Couldn't find keyword? Fill in a default } // ENDIF- Couldn't find keyword? Fill in a default
} // END LoadConf() } // END LoadConf()
void SaveConf()
{
void SaveConf() {
#ifdef VERBOSE_FUNCTION_CONF #ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: SaveConf()"); PrintLog("CDVD config: SaveConf()");
#endif /* VERBOSE_FUNCTION_CONF */ #endif /* VERBOSE_FUNCTION_CONF */
mkdir(confdirname); mkdir(confdirname);
INISaveString(conffilename, "Settings", "IsoFile", conf.isoname); INISaveString(conffilename, "Settings", "IsoFile", conf.isoname);
INISaveString(conffilename, "Settings", "Device", conf.devicename); INISaveString(conffilename, "Settings", "Device", conf.devicename);
INISaveUInt(conffilename, "Settings", "OpenOnStart", conf.startconfigure); INISaveUInt(conffilename, "Settings", "OpenOnStart", conf.startconfigure);
INISaveUInt(conffilename, "Settings", "OpenOnRestart", conf.restartconfigure); INISaveUInt(conffilename, "Settings", "OpenOnRestart", conf.restartconfigure);
} // END SaveConf() } // END SaveConf()

View File

@ -1,108 +1,47 @@
/* conf.h /* conf.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef CONF_H #ifndef CONF_H
#define CONF_H #define CONF_H
#define CDVDdefs #define CDVDdefs
#include "../PS2Edefs.h" #include "../PS2Edefs.h"
#define VERBOSE_FUNCTION_CONF #define VERBOSE_FUNCTION_CONF
// Configuration Data // Configuration Data
typedef struct
{
typedef struct {
u8 isoname[256]; u8 isoname[256];
u8 devicename[256]; u8 devicename[256];
unsigned int startconfigure; unsigned int startconfigure;
unsigned int restartconfigure; unsigned int restartconfigure;
} CDVDconf; } CDVDconf;
extern CDVDconf conf; extern CDVDconf conf;
#define DEFAULT_DEVICE "K:\\" #define DEFAULT_DEVICE "K:\\"
// Configuration Functions // Configuration Functions
extern void InitConf(); extern void InitConf();
extern void LoadConf(); extern void LoadConf();
extern void SaveConf(); extern void SaveConf();
extern void ExecCfg(char *arg); extern void ExecCfg(char *arg);
#endif /* CONF_H */ #endif /* CONF_H */

View File

@ -1,750 +1,370 @@
/* conversionbox.c /* conversionbox.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <windows.h> #include <windows.h>
#include <windowsx.h> // ComboBox_AddString(), CheckDlgButton() #include <windowsx.h> // ComboBox_AddString(), CheckDlgButton()
#include <windef.h> // NULL #include <windef.h> // NULL
// #include <commctrl.h> // #include <commctrl.h>
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <string.h> // strcpy() #include <string.h> // strcpy()
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
#include "isofile.h" #include "isofile.h"
#include "isocompress.h" // compressdesc[] #include "isocompress.h" // compressdesc[]
#include "imagetype.h" // imagedata[] #include "imagetype.h" // imagedata[]
#include "multifile.h" // multinames[] #include "multifile.h" // multinames[]
#include "toc.h" #include "toc.h"
#include "progressbox.h" #include "progressbox.h"
#include "mainbox.h" #include "mainbox.h"
#include "screens.h" // DLG_..., IDC_... #include "screens.h" // DLG_..., IDC_...
#include "conversionbox.h" #include "conversionbox.h"
HWND conversionboxwindow; HWND conversionboxwindow;
void ConversionBoxDestroy()
{
if (conversionboxwindow != NULL)
{
void ConversionBoxDestroy() {
if(conversionboxwindow != NULL) {
EndDialog(conversionboxwindow, FALSE); EndDialog(conversionboxwindow, FALSE);
conversionboxwindow = NULL; conversionboxwindow = NULL;
} // ENDIF- Do we have a Main Window still? } // ENDIF- Do we have a Main Window still?
} // END ConversionBoxDestroy() } // END ConversionBoxDestroy()
void ConversionBoxUnfocus()
{
void ConversionBoxUnfocus() {
// gtk_widget_set_sensitive(conversionbox.file, FALSE); // gtk_widget_set_sensitive(conversionbox.file, FALSE);
// gtk_widget_set_sensitive(conversionbox.selectbutton, FALSE); // gtk_widget_set_sensitive(conversionbox.selectbutton, FALSE);
// gtk_widget_set_sensitive(conversionbox.compress, FALSE); // gtk_widget_set_sensitive(conversionbox.compress, FALSE);
// gtk_widget_set_sensitive(conversionbox.multi, FALSE); // gtk_widget_set_sensitive(conversionbox.multi, FALSE);
// gtk_widget_set_sensitive(conversionbox.okbutton, FALSE); // gtk_widget_set_sensitive(conversionbox.okbutton, FALSE);
// gtk_widget_set_sensitive(conversionbox.cancelbutton, FALSE); // gtk_widget_set_sensitive(conversionbox.cancelbutton, FALSE);
ShowWindow(conversionboxwindow, SW_HIDE); ShowWindow(conversionboxwindow, SW_HIDE);
} // END ConversionBoxUnfocus() } // END ConversionBoxUnfocus()
void ConversionBoxFileEvent()
{
void ConversionBoxFileEvent() {
int returnval; int returnval;
char templine[256]; char templine[256];
struct IsoFile *tempfile; struct IsoFile *tempfile;
GetDlgItemText(conversionboxwindow, IDC_0402, templine, 256); GetDlgItemText(conversionboxwindow, IDC_0402, templine, 256);
returnval = IsIsoFile(templine); returnval = IsIsoFile(templine);
if (returnval == -1)
if(returnval == -1) { {
SetDlgItemText(conversionboxwindow, IDC_0404, "File Type: ---"); SetDlgItemText(conversionboxwindow, IDC_0404, "File Type: ---");
return; return;
} // ENDIF- Not a name of any sort? } // ENDIF- Not a name of any sort?
if (returnval == -2)
{
if(returnval == -2) {
SetDlgItemText(conversionboxwindow, IDC_0404, "File Type: Not a file"); SetDlgItemText(conversionboxwindow, IDC_0404, "File Type: Not a file");
return; return;
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
if (returnval == -3)
{
if(returnval == -3) {
SetDlgItemText(conversionboxwindow, IDC_0404, "File Type: Not a valid image file"); SetDlgItemText(conversionboxwindow, IDC_0404, "File Type: Not a valid image file");
return; return;
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
if (returnval == -4)
{
if(returnval == -4) {
SetDlgItemText(conversionboxwindow, IDC_0404, "File Type: Missing Table File (will rebuild)"); SetDlgItemText(conversionboxwindow, IDC_0404, "File Type: Missing Table File (will rebuild)");
return; return;
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
tempfile = IsoFileOpenForRead(templine); tempfile = IsoFileOpenForRead(templine);
sprintf(templine, "File Type: %s%s%s", sprintf(templine, "File Type: %s%s%s",
multinames[tempfile->multi], multinames[tempfile->multi],
tempfile->imagename, tempfile->imagename,
compressdesc[tempfile->compress]); compressdesc[tempfile->compress]);
SetDlgItemText(conversionboxwindow, IDC_0404, templine); SetDlgItemText(conversionboxwindow, IDC_0404, templine);
tempfile = IsoFileClose(tempfile); tempfile = IsoFileClose(tempfile);
return; return;
} // END ConversionBoxFileEvent() } // END ConversionBoxFileEvent()
void ConversionBoxRefocus()
{
void ConversionBoxRefocus() {
ConversionBoxFileEvent(); ConversionBoxFileEvent();
// gtk_widget_set_sensitive(conversionbox.file, TRUE); // gtk_widget_set_sensitive(conversionbox.file, TRUE);
// gtk_widget_set_sensitive(conversionbox.selectbutton, TRUE); // gtk_widget_set_sensitive(conversionbox.selectbutton, TRUE);
// gtk_widget_set_sensitive(conversionbox.compress, TRUE); // gtk_widget_set_sensitive(conversionbox.compress, TRUE);
// gtk_widget_set_sensitive(conversionbox.multi, TRUE); // gtk_widget_set_sensitive(conversionbox.multi, TRUE);
// gtk_widget_set_sensitive(conversionbox.okbutton, TRUE); // gtk_widget_set_sensitive(conversionbox.okbutton, TRUE);
// gtk_widget_set_sensitive(conversionbox.cancelbutton, TRUE); // gtk_widget_set_sensitive(conversionbox.cancelbutton, TRUE);
// gtk_window_set_focus(GTK_WINDOW(conversionbox.window), conversionbox.file); // gtk_window_set_focus(GTK_WINDOW(conversionbox.window), conversionbox.file);
ShowWindow(conversionboxwindow, SW_SHOW); ShowWindow(conversionboxwindow, SW_SHOW);
SetActiveWindow(conversionboxwindow); SetActiveWindow(conversionboxwindow);
} // END ConversionBoxRefocus() } // END ConversionBoxRefocus()
void ConversionBoxCancelEvent()
{
void ConversionBoxCancelEvent() {
// ShowWindow(conversionboxwindow, SW_HIDE); // ShowWindow(conversionboxwindow, SW_HIDE);
ConversionBoxDestroy(); ConversionBoxDestroy();
MainBoxRefocus(); MainBoxRefocus();
return; return;
} // END ConversionBoxCancelEvent() } // END ConversionBoxCancelEvent()
void ConversionBoxOKEvent()
{
void ConversionBoxOKEvent() {
char templine[256]; char templine[256];
char tempblock[2352]; char tempblock[2352];
char filename[256]; char filename[256];
HWND tempitem; HWND tempitem;
int compressmethod; int compressmethod;
int multi; int multi;
struct IsoFile *fromfile; struct IsoFile *fromfile;
struct IsoFile *tofile; struct IsoFile *tofile;
int i; int i;
off64_t endsector; off64_t endsector;
int stop; int stop;
int retval; int retval;
ConversionBoxUnfocus(); ConversionBoxUnfocus();
GetDlgItemText(conversionboxwindow, IDC_0402, filename, 256); GetDlgItemText(conversionboxwindow, IDC_0402, filename, 256);
if (IsIsoFile(filename) < 0)
if(IsIsoFile(filename) < 0) { {
ConversionBoxRefocus(); ConversionBoxRefocus();
MessageBox(conversionboxwindow, MessageBox(conversionboxwindow,
"Not a Valid Image File.", "Not a Valid Image File.",
"CDVDisoEFP Message", "CDVDisoEFP Message",
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND); MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
return; return;
} // ENDIF- Not an Iso File? Stop early. } // ENDIF- Not an Iso File? Stop early.
tempitem = GetDlgItem(conversionboxwindow, IDC_0406); tempitem = GetDlgItem(conversionboxwindow, IDC_0406);
compressmethod = ComboBox_GetCurSel(tempitem); compressmethod = ComboBox_GetCurSel(tempitem);
tempitem = NULL; tempitem = NULL;
if (compressmethod > 0) compressmethod += 2; if (compressmethod > 0) compressmethod += 2;
multi = 0; multi = 0;
if (IsDlgButtonChecked(conversionboxwindow, IDC_0408)) multi = 1; if (IsDlgButtonChecked(conversionboxwindow, IDC_0408)) multi = 1;
fromfile = NULL; fromfile = NULL;
fromfile = IsoFileOpenForRead(filename); fromfile = IsoFileOpenForRead(filename);
if (fromfile == NULL)
if(fromfile == NULL) { {
ConversionBoxRefocus(); ConversionBoxRefocus();
MessageBox(conversionboxwindow, MessageBox(conversionboxwindow,
"Cannot opening the source file", "Cannot opening the source file",
"CDVDisoEFP Message", "CDVDisoEFP Message",
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND); MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
return; return;
} // ENDIF- Not an Iso File? Stop early. } // ENDIF- Not an Iso File? Stop early.
if ((compressmethod == fromfile->compress) && if ((compressmethod == fromfile->compress) &&
(multi == fromfile->multi))
(multi == fromfile->multi)) { {
fromfile = IsoFileClose(fromfile); fromfile = IsoFileClose(fromfile);
ConversionBoxRefocus(); ConversionBoxRefocus();
MessageBox(conversionboxwindow, MessageBox(conversionboxwindow,
"Compress/Multifile methods match - no need to convert", "Compress/Multifile methods match - no need to convert",
"CDVDisoEFP Message", "CDVDisoEFP Message",
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND); MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
return; return;
} // ENDIF- Not an Iso File? Stop early. } // ENDIF- Not an Iso File? Stop early.
tofile = IsoFileOpenForWrite(filename, tofile = IsoFileOpenForWrite(filename,
GetImageTypeConvertTo(fromfile->imagetype), GetImageTypeConvertTo(fromfile->imagetype),
multi, multi,
compressmethod); compressmethod);
if (tofile == NULL)
if(tofile == NULL) { {
fromfile = IsoFileClose(fromfile); fromfile = IsoFileClose(fromfile);
ConversionBoxRefocus(); ConversionBoxRefocus();
MessageBox(conversionboxwindow, MessageBox(conversionboxwindow,
"Cannot create the new file", "Cannot create the new file",
"CDVDisoEFP Message", "CDVDisoEFP Message",
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND); MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
return; return;
} // ENDIF- Not an Iso File? Stop early. } // ENDIF- Not an Iso File? Stop early.
if (fromfile->multi == 1)
{
if(fromfile->multi == 1) {
i = 0; i = 0;
while ((i < 10) && while ((i < 10) &&
(IsoFileSeek(fromfile, fromfile->multisectorend[i] + 1) == 0)) i++; (IsoFileSeek(fromfile, fromfile->multisectorend[i] + 1) == 0)) i++;
endsector = fromfile->multisectorend[fromfile->multiend]; endsector = fromfile->multisectorend[fromfile->multiend];
}
} else { else
{
endsector = fromfile->filesectorsize; endsector = fromfile->filesectorsize;
} // ENDIF- Get ending sector from multifile? (Or single file?) } // ENDIF- Get ending sector from multifile? (Or single file?)
IsoFileSeek(fromfile, 0); IsoFileSeek(fromfile, 0);
// Open Progress Bar // Open Progress Bar
sprintf(templine, "%s: %s%s -> %s%s", sprintf(templine, "%s: %s%s -> %s%s",
filename, filename,
multinames[fromfile->multi], multinames[fromfile->multi],
compressdesc[fromfile->compress], compressdesc[fromfile->compress],
multinames[tofile->multi], multinames[tofile->multi],
compressdesc[tofile->compress]); compressdesc[tofile->compress]);
ProgressBoxStart(templine, endsector); ProgressBoxStart(templine, endsector);
tofile->cdvdtype = fromfile->cdvdtype; tofile->cdvdtype = fromfile->cdvdtype;
for (i = 0; i < 2048; i++) tofile->toc[i] = fromfile->toc[i]; for (i = 0; i < 2048; i++) tofile->toc[i] = fromfile->toc[i];
stop = 0; stop = 0;
mainboxstop = 0; mainboxstop = 0;
progressboxstop = 0; progressboxstop = 0;
while ((stop == 0) && (tofile->sectorpos < endsector))
while((stop == 0) && (tofile->sectorpos < endsector)) { {
retval = IsoFileRead(fromfile, tempblock); retval = IsoFileRead(fromfile, tempblock);
if (retval < 0)
if(retval < 0) { {
MessageBox(conversionboxwindow, MessageBox(conversionboxwindow,
"Trouble reading source file", "Trouble reading source file",
"CDVDisoEFP Message", "CDVDisoEFP Message",
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND); MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
stop = 1; stop = 1;
}
} else { else
{
retval = IsoFileWrite(tofile, tempblock); retval = IsoFileWrite(tofile, tempblock);
if (retval < 0)
if(retval < 0) { {
MessageBox(conversionboxwindow, MessageBox(conversionboxwindow,
"Trouble writing new file", "Trouble writing new file",
"CDVDisoEFP Message", "CDVDisoEFP Message",
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND); MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
stop = 1; stop = 1;
} // ENDIF- Trouble writing out the next block? } // ENDIF- Trouble writing out the next block?
} // ENDIF- Trouble reading in the next block? } // ENDIF- Trouble reading in the next block?
ProgressBoxTick(tofile->sectorpos); ProgressBoxTick(tofile->sectorpos);
if (mainboxstop != 0) stop = 2; if (mainboxstop != 0) stop = 2;
if (progressboxstop != 0) stop = 2; if (progressboxstop != 0) stop = 2;
} // ENDWHILE- Not stopped for some reason... } // ENDWHILE- Not stopped for some reason...
ProgressBoxStop(); ProgressBoxStop();
if (stop == 0)
{
if(stop == 0) {
if (tofile->multi == 1) tofile->name[tofile->multipos] = '0'; // First file if (tofile->multi == 1) tofile->name[tofile->multipos] = '0'; // First file
strcpy(templine, tofile->name); strcpy(templine, tofile->name);
// fromfile = IsoFileCloseAndDelete(fromfile); // fromfile = IsoFileCloseAndDelete(fromfile);
fromfile = IsoFileClose(fromfile); fromfile = IsoFileClose(fromfile);
IsoSaveTOC(tofile); IsoSaveTOC(tofile);
tofile = IsoFileClose(tofile); tofile = IsoFileClose(tofile);
SetDlgItemText(mainboxwindow, IDC_0202, templine); SetDlgItemText(mainboxwindow, IDC_0202, templine);
}
else
} else { {
fromfile = IsoFileClose(fromfile); fromfile = IsoFileClose(fromfile);
tofile = IsoFileCloseAndDelete(tofile); tofile = IsoFileCloseAndDelete(tofile);
} // ENDIF- Did we succeed in the transfer? } // ENDIF- Did we succeed in the transfer?
ConversionBoxRefocus(); ConversionBoxRefocus();
if (stop == 0) ConversionBoxCancelEvent(); if (stop == 0) ConversionBoxCancelEvent();
return; return;
} // END ConversionBoxOKEvent() } // END ConversionBoxOKEvent()
void ConversionBoxBrowseEvent()
{
void ConversionBoxBrowseEvent() {
OPENFILENAME filebox; OPENFILENAME filebox;
char newfilename[256]; char newfilename[256];
BOOL returnbool; BOOL returnbool;
filebox.lStructSize = sizeof(filebox); filebox.lStructSize = sizeof(filebox);
filebox.hwndOwner = conversionboxwindow; filebox.hwndOwner = conversionboxwindow;
filebox.hInstance = NULL; filebox.hInstance = NULL;
filebox.lpstrFilter = fileselection; filebox.lpstrFilter = fileselection;
filebox.lpstrCustomFilter = NULL; filebox.lpstrCustomFilter = NULL;
filebox.nFilterIndex = 0; filebox.nFilterIndex = 0;
filebox.lpstrFile = newfilename; filebox.lpstrFile = newfilename;
filebox.nMaxFile = 256; filebox.nMaxFile = 256;
filebox.lpstrFileTitle = NULL; filebox.lpstrFileTitle = NULL;
filebox.nMaxFileTitle = 0; filebox.nMaxFileTitle = 0;
filebox.lpstrInitialDir = NULL; filebox.lpstrInitialDir = NULL;
filebox.lpstrTitle = NULL; filebox.lpstrTitle = NULL;
filebox.Flags = OFN_FILEMUSTEXIST filebox.Flags = OFN_FILEMUSTEXIST
| OFN_NOCHANGEDIR | OFN_NOCHANGEDIR
| OFN_HIDEREADONLY; | OFN_HIDEREADONLY;
filebox.nFileOffset = 0; filebox.nFileOffset = 0;
filebox.nFileExtension = 0; filebox.nFileExtension = 0;
filebox.lpstrDefExt = NULL; filebox.lpstrDefExt = NULL;
filebox.lCustData = 0; filebox.lCustData = 0;
filebox.lpfnHook = NULL; filebox.lpfnHook = NULL;
filebox.lpTemplateName = NULL; filebox.lpTemplateName = NULL;
GetDlgItemText(conversionboxwindow, IDC_0402, newfilename, 256); GetDlgItemText(conversionboxwindow, IDC_0402, newfilename, 256);
returnbool = GetOpenFileName(&filebox); returnbool = GetOpenFileName(&filebox);
if (returnbool != FALSE)
if(returnbool != FALSE) { {
SetDlgItemText(conversionboxwindow, IDC_0402, newfilename); SetDlgItemText(conversionboxwindow, IDC_0402, newfilename);
} // ENDIF- User actually selected a name? Save it. } // ENDIF- User actually selected a name? Save it.
return; return;
} // END ConversionBoxBrowseEvent() } // END ConversionBoxBrowseEvent()
void ConversionBoxDisplay()
{
void ConversionBoxDisplay() {
char templine[256]; char templine[256];
HWND itemptr; HWND itemptr;
int itemcount; int itemcount;
// Adjust window position? // Adjust window position?
// Pull the name from the Main Window... for a starting place. // Pull the name from the Main Window... for a starting place.
GetDlgItemText(mainboxwindow, IDC_0202, templine, 256); GetDlgItemText(mainboxwindow, IDC_0202, templine, 256);
SetDlgItemText(conversionboxwindow, IDC_0402, templine); SetDlgItemText(conversionboxwindow, IDC_0402, templine);
// ConversionBoxFileEvent(); // Needed? // ConversionBoxFileEvent(); // Needed?
itemptr = GetDlgItem(conversionboxwindow, IDC_0406); // Compression Combo itemptr = GetDlgItem(conversionboxwindow, IDC_0406); // Compression Combo
itemcount = 0; itemcount = 0;
while (compressnames[itemcount] != NULL)
while(compressnames[itemcount] != NULL) { {
ComboBox_AddString(itemptr, compressnames[itemcount]); ComboBox_AddString(itemptr, compressnames[itemcount]);
itemcount++; itemcount++;
} // ENDWHILE- loading compression types into combo box } // ENDWHILE- loading compression types into combo box
ComboBox_SetCurSel(itemptr, 0); // First Selection? ComboBox_SetCurSel(itemptr, 0); // First Selection?
itemptr = NULL; itemptr = NULL;
CheckDlgButton(conversionboxwindow, IDC_0408, FALSE); // Start unchecked CheckDlgButton(conversionboxwindow, IDC_0408, FALSE); // Start unchecked
return; return;
} // END ConversionBoxDisplay() } // END ConversionBoxDisplay()
BOOL CALLBACK ConversionBoxCallback(HWND window, BOOL CALLBACK ConversionBoxCallback(HWND window,
UINT msg, UINT msg,
WPARAM param, WPARAM param,
LPARAM param2)
LPARAM param2) { {
switch (msg)
switch(msg) { {
case WM_INITDIALOG: case WM_INITDIALOG:
conversionboxwindow = window; conversionboxwindow = window;
ConversionBoxDisplay(); // Final touches to this window ConversionBoxDisplay(); // Final touches to this window
return(FALSE); // Let Windows display this window return(FALSE); // Let Windows display this window
break; break;
case WM_CLOSE: // The "X" in the upper right corner was hit. case WM_CLOSE: // The "X" in the upper right corner was hit.
ConversionBoxCancelEvent(); ConversionBoxCancelEvent();
return(TRUE); return(TRUE);
break; break;
case WM_COMMAND: case WM_COMMAND:
switch (LOWORD(param))
switch(LOWORD(param)) { {
case IDC_0402: // Filename Edit Box case IDC_0402: // Filename Edit Box
ConversionBoxFileEvent(); // Describe the File's current type... ConversionBoxFileEvent(); // Describe the File's current type...
return(FALSE); // Let Windows edit the text. return(FALSE); // Let Windows edit the text.
break; break;
case IDC_0403: // "Browse" Button case IDC_0403: // "Browse" Button
ConversionBoxBrowseEvent(); ConversionBoxBrowseEvent();
return(TRUE); return(TRUE);
break; break;
case IDC_0409: // "Change File" Button case IDC_0409: // "Change File" Button
ConversionBoxOKEvent(); ConversionBoxOKEvent();
return(TRUE); return(TRUE);
break; break;
case IDC_0410: // "Cancel" Button case IDC_0410: // "Cancel" Button
ConversionBoxCancelEvent(); ConversionBoxCancelEvent();
return(TRUE); return(TRUE);
break; break;
} // ENDSWITCH param- Which object got the message? } // ENDSWITCH param- Which object got the message?
} // ENDSWITCH msg- what message has been sent to this window? } // ENDSWITCH msg- what message has been sent to this window?
return(FALSE); return(FALSE);
} // END ConversionBoxEventLoop() } // END ConversionBoxEventLoop()

View File

@ -1,80 +1,35 @@
/* conversionbox.h /* conversionbox.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef CONVERSIONBOX_H #ifndef CONVERSIONBOX_H
#define CONVERSIONBOX_H #define CONVERSIONBOX_H
#include <windows.h> // HWND #include <windows.h> // HWND
extern HWND conversionboxwindow; extern HWND conversionboxwindow;
extern void ConversionBoxDestroy(); extern void ConversionBoxDestroy();
extern void ConversionBoxRefocus(); extern void ConversionBoxRefocus();
extern void ConversionBoxDisplay(); extern void ConversionBoxDisplay();
extern BOOL CALLBACK ConversionBoxCallback(HWND window, extern BOOL CALLBACK ConversionBoxCallback(HWND window,
UINT msg, UINT msg,
WPARAM param, WPARAM param,
LPARAM param2); LPARAM param2);
#endif /* CONVERSIONBOX_H */ #endif /* CONVERSIONBOX_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,128 +1,55 @@
/* device.h /* device.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef __DEVICE_H__ #ifndef __DEVICE_H__
#define __DEVICE_H__ #define __DEVICE_H__
#include <windows.h> // BOOL, DWORD #include <windows.h> // BOOL, DWORD
#include <time.h> // time_t #include <time.h> // time_t
#define CDVDdefs #define CDVDdefs
#include "../PS2Edefs.h" #include "../PS2Edefs.h"
// #define VERBOSE_FUNCTION_DEVICE // #define VERBOSE_FUNCTION_DEVICE
// #define VERBOSE_WARNING_DEVICE // #define VERBOSE_WARNING_DEVICE
#define VERBOSE_DISC_TYPE #define VERBOSE_DISC_TYPE
#define VERBOSE_DISC_INFO #define VERBOSE_DISC_INFO
extern HANDLE devicehandle; extern HANDLE devicehandle;
extern OVERLAPPED waitevent; extern OVERLAPPED waitevent;
extern time_t lasttime; extern time_t lasttime;
extern s32 traystatus; extern s32 traystatus;
extern s32 disctype; extern s32 disctype;
extern char tocbuffer[]; extern char tocbuffer[];
extern void DeviceInit(); extern void DeviceInit();
extern void InitDisc(); extern void InitDisc();
extern s32 DiscInserted(); extern s32 DiscInserted();
extern DWORD FinishCommand(BOOL boolresult); extern DWORD FinishCommand(BOOL boolresult);
extern s32 DeviceOpen(); extern s32 DeviceOpen();
extern void DeviceClose(); extern void DeviceClose();
extern s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer); extern s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 DeviceBufferOffset(); extern s32 DeviceBufferOffset();
extern s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd); extern s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd);
extern s32 DeviceGetDiskType(); extern s32 DeviceGetDiskType();
extern s32 DeviceTrayStatus(); extern s32 DeviceTrayStatus();
extern s32 DeviceTrayOpen(); extern s32 DeviceTrayOpen();
extern s32 DeviceTrayClose(); extern s32 DeviceTrayClose();
#endif /* __DEVICE_H__ */ #endif /* __DEVICE_H__ */

View File

@ -1,818 +1,407 @@
/* devicebox.c /* devicebox.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <windows.h> #include <windows.h>
#include <windowsx.h> // ComboBox_AddString() #include <windowsx.h> // ComboBox_AddString()
#include <windef.h> // NULL #include <windef.h> // NULL
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <string.h> // strcpy() #include <string.h> // strcpy()
#include <sys/stat.h> // stat() #include <sys/stat.h> // stat()
#include <sys/types.h> // stat() #include <sys/types.h> // stat()
#include <unistd.h> // stat() #include <unistd.h> // stat()
#define CDVDdefs #define CDVDdefs
#include "PS2Edefs.h" #include "PS2Edefs.h"
#include "conf.h" #include "conf.h"
#include "device.h" #include "device.h"
#include "isofile.h" #include "isofile.h"
#include "isocompress.h" // compressdesc[] #include "isocompress.h" // compressdesc[]
// #include "imagetype.h" // imagedata[].name // #include "imagetype.h" // imagedata[].name
#include "multifile.h" // multinames[] #include "multifile.h" // multinames[]
#include "toc.h" #include "toc.h"
#include "progressbox.h" #include "progressbox.h"
#include "mainbox.h" #include "mainbox.h"
#include "screens.h" #include "screens.h"
#include "devicebox.h" #include "devicebox.h"
HWND deviceboxwindow; HWND deviceboxwindow;
void DeviceBoxDestroy()
{
if (deviceboxwindow != NULL)
{
void DeviceBoxDestroy() {
if(deviceboxwindow != NULL) {
EndDialog(deviceboxwindow, FALSE); EndDialog(deviceboxwindow, FALSE);
deviceboxwindow = NULL; deviceboxwindow = NULL;
} // ENDIF- Do we have a Main Window still? } // ENDIF- Do we have a Main Window still?
} // END DeviceBoxDestroy() } // END DeviceBoxDestroy()
void DeviceBoxUnfocus()
{
void DeviceBoxUnfocus() {
// gtk_widget_set_sensitive(devicebox.device, FALSE); // gtk_widget_set_sensitive(devicebox.device, FALSE);
// gtk_widget_set_sensitive(devicebox.file, FALSE); // gtk_widget_set_sensitive(devicebox.file, FALSE);
// gtk_widget_set_sensitive(devicebox.selectbutton, FALSE); // gtk_widget_set_sensitive(devicebox.selectbutton, FALSE);
// gtk_widget_set_sensitive(devicebox.compress, FALSE); // gtk_widget_set_sensitive(devicebox.compress, FALSE);
// gtk_widget_set_sensitive(devicebox.multi, FALSE); // gtk_widget_set_sensitive(devicebox.multi, FALSE);
// gtk_widget_set_sensitive(devicebox.okbutton, FALSE); // gtk_widget_set_sensitive(devicebox.okbutton, FALSE);
// gtk_widget_set_sensitive(devicebox.cancelbutton, FALSE); // gtk_widget_set_sensitive(devicebox.cancelbutton, FALSE);
ShowWindow(deviceboxwindow, SW_HIDE); ShowWindow(deviceboxwindow, SW_HIDE);
} // END DeviceBoxUnfocus() } // END DeviceBoxUnfocus()
void DeviceBoxDeviceEvent()
{
void DeviceBoxDeviceEvent() {
char tempdevice[256]; char tempdevice[256];
struct stat filestat; struct stat filestat;
int returnval; int returnval;
GetDlgItemText(deviceboxwindow, IDC_0302, tempdevice, 256); GetDlgItemText(deviceboxwindow, IDC_0302, tempdevice, 256);
returnval = stat(tempdevice, &filestat); returnval = stat(tempdevice, &filestat);
if (returnval == -1)
if(returnval == -1) { {
SetDlgItemText(deviceboxwindow, IDC_0303, "Device Type: ---"); SetDlgItemText(deviceboxwindow, IDC_0303, "Device Type: ---");
return; return;
} // ENDIF- Not a name of any sort? } // ENDIF- Not a name of any sort?
if (S_ISDIR(filestat.st_mode) != 0)
{
if(S_ISDIR(filestat.st_mode) != 0) {
SetDlgItemText(deviceboxwindow, IDC_0303, "Device Type: Not a device"); SetDlgItemText(deviceboxwindow, IDC_0303, "Device Type: Not a device");
return; return;
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
SetDlgItemText(deviceboxwindow, IDC_0303, "Device Type: Device Likely"); SetDlgItemText(deviceboxwindow, IDC_0303, "Device Type: Device Likely");
return; return;
} // END DeviceBoxDeviceEvent() } // END DeviceBoxDeviceEvent()
void DeviceBoxFileEvent()
{
void DeviceBoxFileEvent() {
int returnval; int returnval;
char templine[256]; char templine[256];
struct IsoFile *tempfile; struct IsoFile *tempfile;
GetDlgItemText(deviceboxwindow, IDC_0305, templine, 256); GetDlgItemText(deviceboxwindow, IDC_0305, templine, 256);
returnval = IsIsoFile(templine); returnval = IsIsoFile(templine);
if (returnval == -1)
if(returnval == -1) { {
SetDlgItemText(deviceboxwindow, IDC_0307, "File Type: ---"); SetDlgItemText(deviceboxwindow, IDC_0307, "File Type: ---");
return; return;
} // ENDIF- Not a name of any sort? } // ENDIF- Not a name of any sort?
if (returnval == -2)
{
if(returnval == -2) {
SetDlgItemText(deviceboxwindow, IDC_0307, "File Type: Not a file"); SetDlgItemText(deviceboxwindow, IDC_0307, "File Type: Not a file");
return; return;
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
if (returnval == -3)
{
if(returnval == -3) {
SetDlgItemText(deviceboxwindow, IDC_0307, "File Type: Not a valid image file"); SetDlgItemText(deviceboxwindow, IDC_0307, "File Type: Not a valid image file");
return; return;
} // ENDIF- Not an image file? } // ENDIF- Not an image file?
if (returnval == -4)
{
if(returnval == -4) {
SetDlgItemText(deviceboxwindow, IDC_0307, "File Type: Missing Table File (will rebuild)"); SetDlgItemText(deviceboxwindow, IDC_0307, "File Type: Missing Table File (will rebuild)");
return; return;
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
tempfile = IsoFileOpenForRead(templine); tempfile = IsoFileOpenForRead(templine);
sprintf(templine, "File Type: %s%s%s", sprintf(templine, "File Type: %s%s%s",
multinames[tempfile->multi], multinames[tempfile->multi],
tempfile->imagename, tempfile->imagename,
compressdesc[tempfile->compress]); compressdesc[tempfile->compress]);
SetDlgItemText(deviceboxwindow, IDC_0307, templine); SetDlgItemText(deviceboxwindow, IDC_0307, templine);
tempfile = IsoFileClose(tempfile); tempfile = IsoFileClose(tempfile);
return; return;
} // END DeviceBoxFileEvent() } // END DeviceBoxFileEvent()
void DeviceBoxRefocus()
{
void DeviceBoxRefocus() {
DeviceBoxDeviceEvent(); DeviceBoxDeviceEvent();
DeviceBoxFileEvent(); DeviceBoxFileEvent();
// gtk_widget_set_sensitive(devicebox.device, TRUE); // gtk_widget_set_sensitive(devicebox.device, TRUE);
// gtk_widget_set_sensitive(devicebox.file, TRUE); // gtk_widget_set_sensitive(devicebox.file, TRUE);
// gtk_widget_set_sensitive(devicebox.selectbutton, TRUE); // gtk_widget_set_sensitive(devicebox.selectbutton, TRUE);
// gtk_widget_set_sensitive(devicebox.compress, TRUE); // gtk_widget_set_sensitive(devicebox.compress, TRUE);
// gtk_widget_set_sensitive(devicebox.multi, TRUE); // gtk_widget_set_sensitive(devicebox.multi, TRUE);
// gtk_widget_set_sensitive(devicebox.okbutton, TRUE); // gtk_widget_set_sensitive(devicebox.okbutton, TRUE);
// gtk_widget_set_sensitive(devicebox.cancelbutton, TRUE); // gtk_widget_set_sensitive(devicebox.cancelbutton, TRUE);
// gtk_window_set_focus(GTK_WINDOW(devicebox.window), devicebox.file); // gtk_window_set_focus(GTK_WINDOW(devicebox.window), devicebox.file);
ShowWindow(deviceboxwindow, SW_SHOW); ShowWindow(deviceboxwindow, SW_SHOW);
SetActiveWindow(deviceboxwindow); SetActiveWindow(deviceboxwindow);
} // END DeviceBoxRefocus() } // END DeviceBoxRefocus()
void DeviceBoxCancelEvent()
{
void DeviceBoxCancelEvent() {
// ShowWindow(deviceboxwindow, SW_HIDE); // ShowWindow(deviceboxwindow, SW_HIDE);
DeviceBoxDestroy(); DeviceBoxDestroy();
MainBoxRefocus(); MainBoxRefocus();
return; return;
} // END DeviceBoxCancelEvent() } // END DeviceBoxCancelEvent()
void DeviceBoxOKEvent()
{
void DeviceBoxOKEvent() {
char templine[256]; char templine[256];
u8 tempbuffer[2352]; u8 tempbuffer[2352];
struct IsoFile *tofile; struct IsoFile *tofile;
s32 retval; s32 retval;
cdvdTD cdvdtd; cdvdTD cdvdtd;
int stop; int stop;
HWND tempitem; HWND tempitem;
int compressmethod; int compressmethod;
int multi; int multi;
int imagetype; int imagetype;
int i; int i;
DeviceBoxUnfocus(); DeviceBoxUnfocus();
GetDlgItemText(deviceboxwindow, IDC_0302, conf.devicename, 256); GetDlgItemText(deviceboxwindow, IDC_0302, conf.devicename, 256);
retval = DeviceOpen(); retval = DeviceOpen();
if (retval != 0)
if(retval != 0) { {
DeviceClose(); DeviceClose();
DeviceBoxRefocus(); DeviceBoxRefocus();
MessageBox(deviceboxwindow, MessageBox(deviceboxwindow,
"Could not open the device", "Could not open the device",
"CDVDisoEFP Message", "CDVDisoEFP Message",
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND); MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
return; return;
} // ENDIF- Trouble opening device? Abort here. } // ENDIF- Trouble opening device? Abort here.
DeviceTrayStatus(); DeviceTrayStatus();
retval = DiscInserted(); retval = DiscInserted();
if (retval != 0)
if(retval != 0) { {
DeviceClose(); DeviceClose();
DeviceBoxRefocus(); DeviceBoxRefocus();
MessageBox(deviceboxwindow, MessageBox(deviceboxwindow,
"No disc in the device\r\nPlease put a disc in and try again.", "No disc in the device\r\nPlease put a disc in and try again.",
"CDVDisoEFP Message", "CDVDisoEFP Message",
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND); MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
return; return;
} // ENDIF- Trouble opening device? Abort here. } // ENDIF- Trouble opening device? Abort here.
retval = DeviceGetTD(0, &cdvdtd); // Fish for Ending Sector retval = DeviceGetTD(0, &cdvdtd); // Fish for Ending Sector
if (retval < 0)
if(retval < 0) { {
DeviceClose(); DeviceClose();
DeviceBoxRefocus(); DeviceBoxRefocus();
MessageBox(deviceboxwindow, MessageBox(deviceboxwindow,
"Could not retrieve disc sector size", "Could not retrieve disc sector size",
"CDVDisoEFP Message", "CDVDisoEFP Message",
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND); MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
return; return;
} // ENDIF- Trouble getting disc sector count? } // ENDIF- Trouble getting disc sector count?
tempitem = GetDlgItem(deviceboxwindow, IDC_0309); tempitem = GetDlgItem(deviceboxwindow, IDC_0309);
compressmethod = ComboBox_GetCurSel(tempitem); compressmethod = ComboBox_GetCurSel(tempitem);
tempitem = NULL; tempitem = NULL;
if (compressmethod > 0) compressmethod += 2; if (compressmethod > 0) compressmethod += 2;
multi = 0; multi = 0;
if (IsDlgButtonChecked(deviceboxwindow, IDC_0311)) multi = 1; if (IsDlgButtonChecked(deviceboxwindow, IDC_0311)) multi = 1;
imagetype = 0; imagetype = 0;
if ((disctype != CDVD_TYPE_PS2DVD) && if ((disctype != CDVD_TYPE_PS2DVD) &&
(disctype != CDVD_TYPE_DVDV)) imagetype = 8; (disctype != CDVD_TYPE_DVDV)) imagetype = 8;
GetDlgItemText(deviceboxwindow, IDC_0305, templine, 256); GetDlgItemText(deviceboxwindow, IDC_0305, templine, 256);
tofile = IsoFileOpenForWrite(templine, tofile = IsoFileOpenForWrite(templine,
imagetype, imagetype,
multi, multi,
compressmethod); compressmethod);
if (tofile == NULL)
if(tofile == NULL) { {
DeviceClose(); DeviceClose();
DeviceBoxRefocus(); DeviceBoxRefocus();
MessageBox(deviceboxwindow, MessageBox(deviceboxwindow,
"Could not create the new ISO file", "Could not create the new ISO file",
"CDVDisoEFP Message", "CDVDisoEFP Message",
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND); MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
return; return;
} // ENDIF- Trouble opening the ISO file? } // ENDIF- Trouble opening the ISO file?
// Open Progress Bar // Open Progress Bar
sprintf(templine, "%s -> %s", conf.devicename, tofile->name); sprintf(templine, "%s -> %s", conf.devicename, tofile->name);
ProgressBoxStart(templine, (off64_t) cdvdtd.lsn); ProgressBoxStart(templine, (off64_t) cdvdtd.lsn);
tofile->cdvdtype = disctype; tofile->cdvdtype = disctype;
for (i = 0; i < 2048; i++) tofile->toc[i] = tocbuffer[i]; for (i = 0; i < 2048; i++) tofile->toc[i] = tocbuffer[i];
stop = 0; stop = 0;
mainboxstop = 0; mainboxstop = 0;
progressboxstop = 0; progressboxstop = 0;
while ((stop == 0) && (tofile->sectorpos < cdvdtd.lsn))
while((stop == 0) && (tofile->sectorpos < cdvdtd.lsn)) { {
if (imagetype == 0)
if(imagetype == 0) { {
retval = DeviceReadTrack((u32) tofile->sectorpos, retval = DeviceReadTrack((u32) tofile->sectorpos,
CDVD_MODE_2048, CDVD_MODE_2048,
tempbuffer); tempbuffer);
}
} else { else
{
retval = DeviceReadTrack((u32) tofile->sectorpos, retval = DeviceReadTrack((u32) tofile->sectorpos,
CDVD_MODE_2352, CDVD_MODE_2352,
tempbuffer); tempbuffer);
} // ENDIF- Are we reading a DVD sector? (Or a CD sector?) } // ENDIF- Are we reading a DVD sector? (Or a CD sector?)
if (retval < 0)
if(retval < 0) { {
for (i = 0; i < 2352; i++)
for(i = 0; i < 2352; i++) { {
tempbuffer[i] = 0; tempbuffer[i] = 0;
} // NEXT i- Zeroing the buffer } // NEXT i- Zeroing the buffer
} // ENDIF- Trouble reading next block? } // ENDIF- Trouble reading next block?
retval = IsoFileWrite(tofile, tempbuffer); retval = IsoFileWrite(tofile, tempbuffer);
if (retval < 0)
if(retval < 0) { {
MessageBox(deviceboxwindow, MessageBox(deviceboxwindow,
"Trouble writing new file", "Trouble writing new file",
"CDVDisoEFP Message", "CDVDisoEFP Message",
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND); MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
stop = 1; stop = 1;
} // ENDIF- Trouble writing out the next block? } // ENDIF- Trouble writing out the next block?
ProgressBoxTick(tofile->sectorpos); ProgressBoxTick(tofile->sectorpos);
if (mainboxstop != 0) stop = 2; if (mainboxstop != 0) stop = 2;
if (progressboxstop != 0) stop = 2; if (progressboxstop != 0) stop = 2;
} // ENDWHILE- No reason found to stop... } // ENDWHILE- No reason found to stop...
ProgressBoxStop(); ProgressBoxStop();
if (stop == 0)
{
if(stop == 0) {
if (tofile->multi == 1) tofile->name[tofile->multipos] = '0'; // First file if (tofile->multi == 1) tofile->name[tofile->multipos] = '0'; // First file
strcpy(templine, tofile->name); strcpy(templine, tofile->name);
} // ENDIF- Did we succeed with the transfer? } // ENDIF- Did we succeed with the transfer?
DeviceClose(); DeviceClose();
if (stop == 0)
if(stop == 0) { {
IsoSaveTOC(tofile); IsoSaveTOC(tofile);
tofile = IsoFileClose(tofile); tofile = IsoFileClose(tofile);
SetDlgItemText(mainboxwindow, IDC_0202, templine); SetDlgItemText(mainboxwindow, IDC_0202, templine);
}
} else { else
{
tofile = IsoFileCloseAndDelete(tofile); tofile = IsoFileCloseAndDelete(tofile);
} // ENDIF- (Failed to complete writing file? Get rid of the garbage files.) } // ENDIF- (Failed to complete writing file? Get rid of the garbage files.)
DeviceBoxRefocus(); DeviceBoxRefocus();
if (stop == 0) DeviceBoxCancelEvent(); if (stop == 0) DeviceBoxCancelEvent();
return; return;
} // END DeviceBoxOKEvent() } // END DeviceBoxOKEvent()
void DeviceBoxBrowseEvent()
{
void DeviceBoxBrowseEvent() {
OPENFILENAME filebox; OPENFILENAME filebox;
char newfilename[256]; char newfilename[256];
BOOL returnbool; BOOL returnbool;
filebox.lStructSize = sizeof(filebox); filebox.lStructSize = sizeof(filebox);
filebox.hwndOwner = deviceboxwindow; filebox.hwndOwner = deviceboxwindow;
filebox.hInstance = NULL; filebox.hInstance = NULL;
filebox.lpstrFilter = fileselection; filebox.lpstrFilter = fileselection;
filebox.lpstrCustomFilter = NULL; filebox.lpstrCustomFilter = NULL;
filebox.nFilterIndex = 0; filebox.nFilterIndex = 0;
filebox.lpstrFile = newfilename; filebox.lpstrFile = newfilename;
filebox.nMaxFile = 256; filebox.nMaxFile = 256;
filebox.lpstrFileTitle = NULL; filebox.lpstrFileTitle = NULL;
filebox.nMaxFileTitle = 0; filebox.nMaxFileTitle = 0;
filebox.lpstrInitialDir = NULL; filebox.lpstrInitialDir = NULL;
filebox.lpstrTitle = NULL; filebox.lpstrTitle = NULL;
filebox.Flags = OFN_PATHMUSTEXIST filebox.Flags = OFN_PATHMUSTEXIST
| OFN_NOCHANGEDIR | OFN_NOCHANGEDIR
| OFN_HIDEREADONLY; | OFN_HIDEREADONLY;
filebox.nFileOffset = 0; filebox.nFileOffset = 0;
filebox.nFileExtension = 0; filebox.nFileExtension = 0;
filebox.lpstrDefExt = NULL; filebox.lpstrDefExt = NULL;
filebox.lCustData = 0; filebox.lCustData = 0;
filebox.lpfnHook = NULL; filebox.lpfnHook = NULL;
filebox.lpTemplateName = NULL; filebox.lpTemplateName = NULL;
GetDlgItemText(deviceboxwindow, IDC_0305, newfilename, 256); GetDlgItemText(deviceboxwindow, IDC_0305, newfilename, 256);
returnbool = GetOpenFileName(&filebox); returnbool = GetOpenFileName(&filebox);
if (returnbool != FALSE)
if(returnbool != FALSE) { {
SetDlgItemText(deviceboxwindow, IDC_0305, newfilename); SetDlgItemText(deviceboxwindow, IDC_0305, newfilename);
} // ENDIF- User actually selected a name? Save it. } // ENDIF- User actually selected a name? Save it.
return; return;
} // END DeviceBoxBrowseEvent() } // END DeviceBoxBrowseEvent()
void DeviceBoxDisplay()
{
void DeviceBoxDisplay() {
char templine[256]; char templine[256];
HWND itemptr; HWND itemptr;
int itemcount; int itemcount;
// Adjust Window Position? // Adjust Window Position?
SetDlgItemText(deviceboxwindow, IDC_0302, conf.devicename); SetDlgItemText(deviceboxwindow, IDC_0302, conf.devicename);
// DeviceBoxDeviceEvent(); // Needed? // DeviceBoxDeviceEvent(); // Needed?
GetDlgItemText(mainboxwindow, IDC_0202, templine, 256); GetDlgItemText(mainboxwindow, IDC_0202, templine, 256);
SetDlgItemText(deviceboxwindow, IDC_0305, templine); SetDlgItemText(deviceboxwindow, IDC_0305, templine);
// DeviceBoxFileEvent(); // Needed? // DeviceBoxFileEvent(); // Needed?
itemptr = GetDlgItem(deviceboxwindow, IDC_0309); // Compression Combo itemptr = GetDlgItem(deviceboxwindow, IDC_0309); // Compression Combo
itemcount = 0; itemcount = 0;
while (compressnames[itemcount] != NULL)
while(compressnames[itemcount] != NULL) { {
ComboBox_AddString(itemptr, compressnames[itemcount]); ComboBox_AddString(itemptr, compressnames[itemcount]);
itemcount++; itemcount++;
} // ENDWHILE- loading compression types into combo box } // ENDWHILE- loading compression types into combo box
ComboBox_SetCurSel(itemptr, 0); // First Selection? ComboBox_SetCurSel(itemptr, 0); // First Selection?
itemptr = NULL; itemptr = NULL;
CheckDlgButton(deviceboxwindow, IDC_0311, FALSE); // Start unchecked CheckDlgButton(deviceboxwindow, IDC_0311, FALSE); // Start unchecked
DeviceInit(); // Initialize device access DeviceInit(); // Initialize device access
} // END DeviceBoxDisplay() } // END DeviceBoxDisplay()
BOOL CALLBACK DeviceBoxCallback(HWND window, BOOL CALLBACK DeviceBoxCallback(HWND window,
UINT msg, UINT msg,
WPARAM param, WPARAM param,
LPARAM param2)
LPARAM param2) { {
switch (msg)
switch(msg) { {
case WM_INITDIALOG: case WM_INITDIALOG:
deviceboxwindow = window; deviceboxwindow = window;
DeviceBoxDisplay(); // Final touches to this window DeviceBoxDisplay(); // Final touches to this window
return(FALSE); // Let Windows display this window return(FALSE); // Let Windows display this window
break; break;
case WM_CLOSE: // The "X" in the upper right corner was hit. case WM_CLOSE: // The "X" in the upper right corner was hit.
DeviceBoxCancelEvent(); DeviceBoxCancelEvent();
return(TRUE); return(TRUE);
break; break;
case WM_COMMAND: case WM_COMMAND:
switch (LOWORD(param))
switch(LOWORD(param)) { {
case IDC_0302: // Device Edit Box case IDC_0302: // Device Edit Box
DeviceBoxDeviceEvent(); DeviceBoxDeviceEvent();
return(FALSE); return(FALSE);
break; break;
case IDC_0305: // Filename Edit Box case IDC_0305: // Filename Edit Box
DeviceBoxFileEvent(); DeviceBoxFileEvent();
return(FALSE); return(FALSE);
break; break;
case IDC_0306: // "Browse" Button case IDC_0306: // "Browse" Button
DeviceBoxBrowseEvent(); DeviceBoxBrowseEvent();
return(TRUE); return(TRUE);
break; break;
case IDC_0312: // "Make File" Button case IDC_0312: // "Make File" Button
DeviceBoxOKEvent(); DeviceBoxOKEvent();
return(TRUE); return(TRUE);
break; break;
case IDC_0313: // "Cancel" Button case IDC_0313: // "Cancel" Button
DeviceBoxCancelEvent(); DeviceBoxCancelEvent();
return(TRUE); return(TRUE);
break; break;
} // ENDSWITCH param- Which object got the message? } // ENDSWITCH param- Which object got the message?
} // ENDSWITCH msg- What message has been sent to this window? } // ENDSWITCH msg- What message has been sent to this window?
return(FALSE); return(FALSE);
} // END DeviceBoxCallback() } // END DeviceBoxCallback()

View File

@ -1,82 +1,36 @@
/* devicebox.h /* devicebox.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef DEVICEBOX_H #ifndef DEVICEBOX_H
#define DEVICEBOX_H #define DEVICEBOX_H
#include <windows.h> // HWND #include <windows.h> // HWND
extern HWND deviceboxwindow; extern HWND deviceboxwindow;
extern void DeviceBoxDestroy(); extern void DeviceBoxDestroy();
// extern void DeviceBoxUnfocus(); // extern void DeviceBoxUnfocus();
extern void DeviceBoxRefocus(); extern void DeviceBoxRefocus();
extern void DeviceBoxDisplay(); extern void DeviceBoxDisplay();
extern BOOL CALLBACK DeviceBoxCallback(HWND window, extern BOOL CALLBACK DeviceBoxCallback(HWND window,
UINT msg, UINT msg,
WPARAM param, WPARAM param,
LPARAM param2); LPARAM param2);
#endif /* DEVICEBOX_H */ #endif /* DEVICEBOX_H */

View File

@ -1,238 +1,126 @@
/* logfile.c /* logfile.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <windows.h> #include <windows.h>
// #include <fcntl.h> // open() // #include <fcntl.h> // open()
// #include <io.h> // mkdir() // #include <io.h> // mkdir()
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <stdio.h> // vsprintf() #include <stdio.h> // vsprintf()
#include <stdarg.h> // va_start(), va_end(), vsprintf() #include <stdarg.h> // va_start(), va_end(), vsprintf()
// #include <sys/stat.h> // open() // #include <sys/stat.h> // open()
// #include <sys/types.h> // open() // #include <sys/types.h> // open()
#include "logfile.h" #include "logfile.h"
HANDLE logfile; HANDLE logfile;
char logfiletemp[2048]; char logfiletemp[2048];
void InitLog()
{
void InitLog() {
// Token comment line // Token comment line
#ifdef VERBOSE_LOGFILE #ifdef VERBOSE_LOGFILE
CreateDirectory("logs", NULL); CreateDirectory("logs", NULL);
DeleteFile("logs\\CDVDlog.txt"); DeleteFile("logs\\CDVDlog.txt");
logfile = NULL; logfile = NULL;
#endif /* VERBOSE LOGFILE */ #endif /* VERBOSE LOGFILE */
} // END InitLog(); } // END InitLog();
int OpenLog()
{
int OpenLog() {
// Token comment line // Token comment line
#ifdef VERBOSE_LOGFILE #ifdef VERBOSE_LOGFILE
logfile = CreateFile("logs\\CDVDlog.txt", logfile = CreateFile("logs\\CDVDlog.txt",
GENERIC_WRITE, GENERIC_WRITE,
0, 0,
NULL, NULL,
CREATE_ALWAYS, CREATE_ALWAYS,
FILE_FLAG_SEQUENTIAL_SCAN, FILE_FLAG_SEQUENTIAL_SCAN,
NULL); NULL);
if (logfile == INVALID_HANDLE_VALUE)
if(logfile == INVALID_HANDLE_VALUE) { {
logfile = NULL; logfile = NULL;
return(-1); return(-1);
} // ENDIF- Failed to open? Say so. } // ENDIF- Failed to open? Say so.
#endif /* VERBOSE LOGFILE */ #endif /* VERBOSE LOGFILE */
return(0); return(0);
} // END OpenLog(); } // END OpenLog();
void CloseLog()
{
void CloseLog() {
// Token comment line // Token comment line
#ifdef VERBOSE_LOGFILE #ifdef VERBOSE_LOGFILE
if (logfile != NULL)
if(logfile != NULL) { {
CloseHandle(logfile); CloseHandle(logfile);
logfile = NULL; logfile = NULL;
} // ENDIF- Is the log file actually open? Close it. } // ENDIF- Is the log file actually open? Close it.
#endif /* VERBOSE LOGFILE */ #endif /* VERBOSE LOGFILE */
} // END CloseLog() } // END CloseLog()
void PrintLog(const char *fmt, ...)
{
void PrintLog(const char *fmt, ...) {
DWORD byteswritten; DWORD byteswritten;
// Token comment line // Token comment line
#ifdef VERBOSE_LOGFILE #ifdef VERBOSE_LOGFILE
va_list list; va_list list;
int len; int len;
if (logfile == NULL) return; // Log file not open... yet. if (logfile == NULL) return; // Log file not open... yet.
va_start(list, fmt); va_start(list, fmt);
vsprintf(logfiletemp, fmt, list); vsprintf(logfiletemp, fmt, list);
va_end(list); va_end(list);
len = 0; len = 0;
while ((len < 2048) && (logfiletemp[len] != 0)) len++; while ((len < 2048) && (logfiletemp[len] != 0)) len++;
if ((len > 0) && (logfiletemp[len-1] == '\n')) len--; if ((len > 0) && (logfiletemp[len-1] == '\n')) len--;
if ((len > 0) && (logfiletemp[len-1] == '\r')) len--; if ((len > 0) && (logfiletemp[len-1] == '\r')) len--;
logfiletemp[len] = 0; // Slice off the last "\r\n"... logfiletemp[len] = 0; // Slice off the last "\r\n"...
WriteFile(logfile, logfiletemp, len, &byteswritten, NULL); WriteFile(logfile, logfiletemp, len, &byteswritten, NULL);
WriteFile(logfile, "\r\n", 2, &byteswritten, NULL); WriteFile(logfile, "\r\n", 2, &byteswritten, NULL);
#endif /* VERBOSE LOGFILE */ #endif /* VERBOSE LOGFILE */
} // END PrintLog() } // END PrintLog()
void PrintError(const char *header, DWORD errcode)
{
void PrintError(const char *header, DWORD errcode) {
#ifdef VERBOSE_LOGFILE #ifdef VERBOSE_LOGFILE
TCHAR errmsg[256]; TCHAR errmsg[256];
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | 80, FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | 80,
NULL, NULL,
errcode, errcode,
0, 0,
errmsg, errmsg,
256, 256,
NULL); NULL);
PrintLog("%s: (%u) %s", header, errcode, errmsg); PrintLog("%s: (%u) %s", header, errcode, errmsg);
#endif /* VERBOSE_WARNING_DEVICE */ #endif /* VERBOSE_WARNING_DEVICE */
} // END PrintError() } // END PrintError()

View File

@ -1,78 +1,34 @@
/* logfile.h /* logfile.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef LOGFILE_H #ifndef LOGFILE_H
#define LOGFILE_H #define LOGFILE_H
#include <windows.h> // Just for DWORD #include <windows.h> // Just for DWORD
#define VERBOSE_LOGFILE #define VERBOSE_LOGFILE
extern void InitLog(); extern void InitLog();
extern int OpenLog(); extern int OpenLog();
extern void CloseLog(); extern void CloseLog();
extern void PrintLog(const char *format, ...); extern void PrintLog(const char *format, ...);
extern void PrintError(const char *header, DWORD errcode); extern void PrintError(const char *header, DWORD errcode);
#endif /* LOGFILE_H */ #endif /* LOGFILE_H */

View File

@ -15,15 +15,11 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <windows.h> #include <windows.h>
#include <windowsx.h> // Button_ #include <windowsx.h> // Button_
#include <windef.h> // NULL #include <windef.h> // NULL
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <string.h> // strcpy() #include <string.h> // strcpy()
#include "conf.h" #include "conf.h"
#include "isofile.h" #include "isofile.h"
#include "isocompress.h" // compressdesc[] #include "isocompress.h" // compressdesc[]
@ -37,27 +33,24 @@
#include "CDVDiso.h" // progmodule #include "CDVDiso.h" // progmodule
#include "mainbox.h" #include "mainbox.h"
const char fileselection[] = "\Disc Image Files (*.bin,*.img,*.iso,*.nrg)\0*.bin;*.img;*.iso;*.nrg\0\All Files (*.*)\0*.*\0\\0\0"; const char fileselection[] = "\Disc Image Files (*.bin,*.img,*.iso,*.nrg)\0*.bin;*.img;*.iso;*.nrg\0\All Files (*.*)\0*.*\0\\0\0";
HWND mainboxwindow; HWND mainboxwindow;
int mainboxstop; int mainboxstop;
void MainBoxDestroy()
{
void MainBoxDestroy() { if (progressboxwindow != NULL)
if(progressboxwindow != NULL) { {
ProgressBoxDestroy(); ProgressBoxDestroy();
} // ENDIF- Do we have a Progress Window still? } // ENDIF- Do we have a Progress Window still?
if (mainboxwindow != NULL)
if(mainboxwindow != NULL) { {
EndDialog(mainboxwindow, FALSE); EndDialog(mainboxwindow, FALSE);
mainboxwindow = NULL; mainboxwindow = NULL;
} // ENDIF- Do we have a Main Window still? } // ENDIF- Do we have a Main Window still?
} // END MainBoxDestroy() } // END MainBoxDestroy()
void MainBoxUnfocus()
{
void MainBoxUnfocus() {
// EnableWindow(?) // EnableWindow(?)
// gtk_widget_set_sensitive(mainbox.file, FALSE); // gtk_widget_set_sensitive(mainbox.file, FALSE);
// gtk_widget_set_sensitive(mainbox.selectbutton, FALSE); // gtk_widget_set_sensitive(mainbox.selectbutton, FALSE);
@ -66,31 +59,31 @@ void MainBoxUnfocus() {
// gtk_widget_set_sensitive(mainbox.convbutton, FALSE); // gtk_widget_set_sensitive(mainbox.convbutton, FALSE);
ShowWindow(mainboxwindow, SW_HIDE); ShowWindow(mainboxwindow, SW_HIDE);
} // END MainBoxUnfocus() } // END MainBoxUnfocus()
void MainBoxFileEvent()
{
void MainBoxFileEvent() {
int returnval; int returnval;
char templine[256]; char templine[256];
struct IsoFile *tempfile; struct IsoFile *tempfile;
GetDlgItemText(mainboxwindow, IDC_0202, templine, 256); GetDlgItemText(mainboxwindow, IDC_0202, templine, 256);
returnval = IsIsoFile(templine); returnval = IsIsoFile(templine);
if(returnval == -1) { if (returnval == -1)
{
SetDlgItemText(mainboxwindow, IDC_0204, "File Type: ---"); SetDlgItemText(mainboxwindow, IDC_0204, "File Type: ---");
return; return;
} // ENDIF- Not a name of any sort? } // ENDIF- Not a name of any sort?
if (returnval == -2)
if(returnval == -2) { {
SetDlgItemText(mainboxwindow, IDC_0204, "File Type: Not a file"); SetDlgItemText(mainboxwindow, IDC_0204, "File Type: Not a file");
return; return;
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
if (returnval == -3)
if(returnval == -3) { {
SetDlgItemText(mainboxwindow, IDC_0204, "File Type: Not a valid image file"); SetDlgItemText(mainboxwindow, IDC_0204, "File Type: Not a valid image file");
return; return;
} // ENDIF- Not an Image file? } // ENDIF- Not an Image file?
if (returnval == -4)
if(returnval == -4) { {
SetDlgItemText(mainboxwindow, IDC_0204, "File Type: Missing Table File (will rebuild)"); SetDlgItemText(mainboxwindow, IDC_0204, "File Type: Missing Table File (will rebuild)");
return; return;
} // ENDIF- Missing Compression seek table? } // ENDIF- Missing Compression seek table?
@ -105,10 +98,9 @@ void MainBoxFileEvent() {
return; return;
} // END MainBoxFileEvent() } // END MainBoxFileEvent()
void MainBoxRefocus()
void MainBoxRefocus() { {
MainBoxFileEvent(); MainBoxFileEvent();
// gtk_widget_set_sensitive(mainbox.file, TRUE); // gtk_widget_set_sensitive(mainbox.file, TRUE);
// gtk_widget_set_sensitive(mainbox.selectbutton, TRUE); // gtk_widget_set_sensitive(mainbox.selectbutton, TRUE);
// gtk_widget_set_sensitive(mainbox.okbutton, TRUE); // gtk_widget_set_sensitive(mainbox.okbutton, TRUE);
@ -120,29 +112,28 @@ void MainBoxRefocus() {
SetActiveWindow(mainboxwindow); SetActiveWindow(mainboxwindow);
} // END MainBoxRefocus() } // END MainBoxRefocus()
void MainBoxCancelEvent()
void MainBoxCancelEvent() { {
mainboxstop = 1; // Halt all long processess... mainboxstop = 1; // Halt all long processess...
MainBoxDestroy(); MainBoxDestroy();
return; return;
} // END MainBoxCancelEvent() } // END MainBoxCancelEvent()
void MainBoxOKEvent()
void MainBoxOKEvent() { {
char tempisoname[256]; char tempisoname[256];
MainBoxUnfocus(); MainBoxUnfocus();
GetDlgItemText(mainboxwindow, IDC_0202, tempisoname, 256); GetDlgItemText(mainboxwindow, IDC_0202, tempisoname, 256);
if(*(tempisoname) != 0) { if (*(tempisoname) != 0)
if(IsIsoFile(tempisoname) == -4) { {
if (IsIsoFile(tempisoname) == -4)
{
IsoTableRebuild(tempisoname); IsoTableRebuild(tempisoname);
MainBoxRefocus(); MainBoxRefocus();
return; return;
} // ENDIF- Do we need to rebuild an image file's index before using it? } // ENDIF- Do we need to rebuild an image file's index before using it?
if (IsIsoFile(tempisoname) < 0)
if(IsIsoFile(tempisoname) < 0) { {
MainBoxRefocus(); MainBoxRefocus();
MessageBox(mainboxwindow, MessageBox(mainboxwindow,
"Not a Valid Image File.", "Not a Valid Image File.",
@ -151,16 +142,21 @@ void MainBoxOKEvent() {
return; return;
} // ENDIF- Not an ISO file? Message and Stop here. } // ENDIF- Not an ISO file? Message and Stop here.
} // ENDIF- Do we have a name to check out? } // ENDIF- Do we have a name to check out?
strcpy(conf.isoname, tempisoname); strcpy(conf.isoname, tempisoname);
if(Button_GetCheck(GetDlgItem(mainboxwindow, IDC_0209)) == BST_UNCHECKED) { if (Button_GetCheck(GetDlgItem(mainboxwindow, IDC_0209)) == BST_UNCHECKED)
{
conf.startconfigure = 0; // FALSE conf.startconfigure = 0; // FALSE
} else { }
else
{
conf.startconfigure = 1; // TRUE conf.startconfigure = 1; // TRUE
} // ENDIF- Was this checkbox unchecked? } // ENDIF- Was this checkbox unchecked?
if(Button_GetCheck(GetDlgItem(mainboxwindow, IDC_0210)) == BST_UNCHECKED) { if (Button_GetCheck(GetDlgItem(mainboxwindow, IDC_0210)) == BST_UNCHECKED)
{
conf.restartconfigure = 0; // FALSE conf.restartconfigure = 0; // FALSE
} else { }
else
{
conf.restartconfigure = 1; // TRUE conf.restartconfigure = 1; // TRUE
} // ENDIF- Was this checkbox unchecked? } // ENDIF- Was this checkbox unchecked?
SaveConf(); SaveConf();
@ -169,12 +165,11 @@ void MainBoxOKEvent() {
return; return;
} // END MainBoxOKEvent() } // END MainBoxOKEvent()
void MainBoxBrowseEvent()
void MainBoxBrowseEvent() { {
OPENFILENAME filebox; OPENFILENAME filebox;
char newfilename[256]; char newfilename[256];
BOOL returnbool; BOOL returnbool;
filebox.lStructSize = sizeof(filebox); filebox.lStructSize = sizeof(filebox);
filebox.hwndOwner = mainboxwindow; filebox.hwndOwner = mainboxwindow;
filebox.hInstance = NULL; filebox.hInstance = NULL;
@ -196,29 +191,26 @@ void MainBoxBrowseEvent() {
filebox.lCustData = 0; filebox.lCustData = 0;
filebox.lpfnHook = NULL; filebox.lpfnHook = NULL;
filebox.lpTemplateName = NULL; filebox.lpTemplateName = NULL;
GetDlgItemText(mainboxwindow, IDC_0202, newfilename, 256); GetDlgItemText(mainboxwindow, IDC_0202, newfilename, 256);
returnbool = GetOpenFileName(&filebox); returnbool = GetOpenFileName(&filebox);
if(returnbool != FALSE) { if (returnbool != FALSE)
{
SetDlgItemText(mainboxwindow, IDC_0202, newfilename); SetDlgItemText(mainboxwindow, IDC_0202, newfilename);
} // ENDIF- User actually selected a name? Save it. } // ENDIF- User actually selected a name? Save it.
return; return;
} // END MainBoxBrowseEvent() } // END MainBoxBrowseEvent()
void MainBoxDeviceEvent()
void MainBoxDeviceEvent() { {
MainBoxUnfocus(); MainBoxUnfocus();
DialogBox(progmodule, DialogBox(progmodule,
MAKEINTRESOURCE(DLG_0300), MAKEINTRESOURCE(DLG_0300),
mainboxwindow, mainboxwindow,
(DLGPROC)DeviceBoxCallback); (DLGPROC)DeviceBoxCallback);
return; return;
} // END MainBoxBrowseEvent() } // END MainBoxBrowseEvent()
void MainBoxConversionEvent()
{
void MainBoxConversionEvent() {
MainBoxUnfocus(); MainBoxUnfocus();
DialogBox(progmodule, DialogBox(progmodule,
@ -227,67 +219,64 @@ void MainBoxConversionEvent() {
(DLGPROC)ConversionBoxCallback); (DLGPROC)ConversionBoxCallback);
return; return;
} // END MainBoxBrowseEvent() } // END MainBoxBrowseEvent()
void MainBoxDisplay()
{
void MainBoxDisplay() {
LoadConf(); LoadConf();
// Adjust window position? // Adjust window position?
// We held off setting the name until now... so description would show. // We held off setting the name until now... so description would show.
SetDlgItemText(mainboxwindow, IDC_0202, conf.isoname); SetDlgItemText(mainboxwindow, IDC_0202, conf.isoname);
if(conf.startconfigure == 0) { if (conf.startconfigure == 0)
{
Button_SetCheck(GetDlgItem(mainboxwindow, IDC_0209), BST_UNCHECKED); Button_SetCheck(GetDlgItem(mainboxwindow, IDC_0209), BST_UNCHECKED);
} else { }
else
{
Button_SetCheck(GetDlgItem(mainboxwindow, IDC_0209), BST_CHECKED); Button_SetCheck(GetDlgItem(mainboxwindow, IDC_0209), BST_CHECKED);
} // ENDIF- Do we need to uncheck this box? } // ENDIF- Do we need to uncheck this box?
if(conf.restartconfigure == 0) { if (conf.restartconfigure == 0)
{
Button_SetCheck(GetDlgItem(mainboxwindow, IDC_0210), BST_UNCHECKED); Button_SetCheck(GetDlgItem(mainboxwindow, IDC_0210), BST_UNCHECKED);
} else { }
else
{
Button_SetCheck(GetDlgItem(mainboxwindow, IDC_0210), BST_CHECKED); Button_SetCheck(GetDlgItem(mainboxwindow, IDC_0210), BST_CHECKED);
} // ENDIF- Do we need to uncheck this box? } // ENDIF- Do we need to uncheck this box?
// First Time - Show the window // First Time - Show the window
ShowWindow(mainboxwindow, SW_SHOWNORMAL); ShowWindow(mainboxwindow, SW_SHOWNORMAL);
} // END MainBoxDisplay() } // END MainBoxDisplay()
BOOL CALLBACK MainBoxCallback(HWND window, BOOL CALLBACK MainBoxCallback(HWND window,
UINT msg, UINT msg,
WPARAM param, WPARAM param,
LPARAM param2) { LPARAM param2)
switch(msg) { {
switch (msg)
{
case WM_INITDIALOG: case WM_INITDIALOG:
mainboxwindow = window; mainboxwindow = window;
MainBoxDisplay(); // In this case, final touches to this window. MainBoxDisplay(); // In this case, final touches to this window.
ProgressBoxDisplay(); // Create the Progress Box at this time. ProgressBoxDisplay(); // Create the Progress Box at this time.
return(FALSE); // And let Windows display this window. return(FALSE); // And let Windows display this window.
break; break;
case WM_CLOSE: // The "X" in the upper right corner was hit. case WM_CLOSE: // The "X" in the upper right corner was hit.
MainBoxCancelEvent(); MainBoxCancelEvent();
return(TRUE); return(TRUE);
break; break;
case WM_COMMAND: case WM_COMMAND:
// Do we wish to capture 'ENTER/RETURN' and/or 'ESC' here? // Do we wish to capture 'ENTER/RETURN' and/or 'ESC' here?
switch (LOWORD(param))
switch(LOWORD(param)) { {
case IDC_0202: // Filename Edit Box case IDC_0202: // Filename Edit Box
MainBoxFileEvent(); // Describe the File's type... MainBoxFileEvent(); // Describe the File's type...
return(FALSE); // Let Windows handle the actual 'edit' processing... return(FALSE); // Let Windows handle the actual 'edit' processing...
break; break;
case IDC_0203: // "Browse" Button case IDC_0203: // "Browse" Button
MainBoxBrowseEvent(); MainBoxBrowseEvent();
return(TRUE); return(TRUE);
break; break;
case IDC_0205: // "Ok" Button case IDC_0205: // "Ok" Button
MainBoxOKEvent(); MainBoxOKEvent();
return(TRUE); return(TRUE);
break; break;
case IDC_0206: // "Get from Disc" Button case IDC_0206: // "Get from Disc" Button
MainBoxDeviceEvent(); MainBoxDeviceEvent();
return(TRUE); return(TRUE);
@ -297,13 +286,11 @@ BOOL CALLBACK MainBoxCallback(HWND window,
MainBoxConversionEvent(); MainBoxConversionEvent();
return(TRUE); return(TRUE);
break; break;
case IDC_0208: // "Cancel" Button case IDC_0208: // "Cancel" Button
MainBoxCancelEvent(); MainBoxCancelEvent();
return(TRUE); return(TRUE);
break; break;
} // ENDSWITCH param- Which object got the message? } // ENDSWITCH param- Which object got the message?
} // ENDSWITCH msg- what message has been sent to this window? } // ENDSWITCH msg- what message has been sent to this window?
return(FALSE); // Not a recognized message? Tell Windows to handle it. return(FALSE); // Not a recognized message? Tell Windows to handle it.
} // END MainBoxEventLoop() } // END MainBoxEventLoop()

View File

@ -1,86 +1,37 @@
/* mainbox.h /* mainbox.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef MAINBOX_H #ifndef MAINBOX_H
#define MAINBOX_H #define MAINBOX_H
#include <windows.h> // HWND #include <windows.h> // HWND
extern const char fileselection[]; extern const char fileselection[];
extern HWND mainboxwindow; extern HWND mainboxwindow;
extern int mainboxstop; extern int mainboxstop;
extern void MainBoxRefocus(); extern void MainBoxRefocus();
extern void MainBoxDisplay(); extern void MainBoxDisplay();
extern BOOL CALLBACK MainBoxCallback(HWND window, extern BOOL CALLBACK MainBoxCallback(HWND window,
UINT msg, UINT msg,
WPARAM param, WPARAM param,
LPARAM param2); LPARAM param2);
#endif /* MAINBOX_H */ #endif /* MAINBOX_H */

View File

@ -1,340 +1,165 @@
/* progressbox.c /* progressbox.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <windows.h> #include <windows.h>
#include <windowsx.h> // Enable_Button() #include <windowsx.h> // Enable_Button()
#include <windef.h> // NULL #include <windef.h> // NULL
#include <commctrl.h> // PBM_... #include <commctrl.h> // PBM_...
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <string.h> // strcat() #include <string.h> // strcat()
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
#include "CDVDiso.h" // progmodule #include "CDVDiso.h" // progmodule
#include "screens.h" #include "screens.h"
#include "mainbox.h" #include "mainbox.h"
#include "progressbox.h" #include "progressbox.h"
HWND progressboxwindow; HWND progressboxwindow;
HWND progressboxbar; HWND progressboxbar;
int progressboxstop; int progressboxstop;
off64_t progressboxmax; off64_t progressboxmax;
off64_t progressboxlastpct; off64_t progressboxlastpct;
char progressboxline[256]; char progressboxline[256];
char progressboxmaxchar[16]; char progressboxmaxchar[16];
void ProgressBoxDestroy()
{
if (progressboxwindow != NULL)
{
void ProgressBoxDestroy() {
if(progressboxwindow != NULL) {
DestroyWindow(progressboxwindow); DestroyWindow(progressboxwindow);
progressboxwindow = NULL; progressboxwindow = NULL;
progressboxbar = NULL; progressboxbar = NULL;
} // ENDIF- Do we have a Progress Window still? } // ENDIF- Do we have a Progress Window still?
return; return;
} // END ProgressBoxDestroy() } // END ProgressBoxDestroy()
void ProgressBoxStart(char *description, off64_t maximum)
{
void ProgressBoxStart(char *description, off64_t maximum) {
SetDlgItemText(progressboxwindow, IDC_0501, description); SetDlgItemText(progressboxwindow, IDC_0501, description);
progressboxmax = maximum; progressboxmax = maximum;
sprintf(progressboxmaxchar, "%llu", maximum); sprintf(progressboxmaxchar, "%llu", maximum);
progressboxlastpct = 100; progressboxlastpct = 100;
progressboxstop = 0; progressboxstop = 0;
ProgressBoxTick(0); ProgressBoxTick(0);
ShowWindow(progressboxwindow, SW_SHOW); ShowWindow(progressboxwindow, SW_SHOW);
SetForegroundWindow(progressboxwindow); SetForegroundWindow(progressboxwindow);
return; return;
} // END ProgressBoxStart() } // END ProgressBoxStart()
void ProgressBoxTick(off64_t current)
{
void ProgressBoxTick(off64_t current) {
off64_t thispct; off64_t thispct;
MSG msg; MSG msg;
BOOL returnbool; BOOL returnbool;
sprintf(progressboxline, "%llu of ", current); sprintf(progressboxline, "%llu of ", current);
strcat(progressboxline, progressboxmaxchar); strcat(progressboxline, progressboxmaxchar);
SetDlgItemText(progressboxwindow, IDC_0503, progressboxline); SetDlgItemText(progressboxwindow, IDC_0503, progressboxline);
if (progressboxmax >= 30000)
{
if(progressboxmax >= 30000 ) {
SendMessage(progressboxbar, PBM_SETPOS, current / (progressboxmax / 30000), 0); SendMessage(progressboxbar, PBM_SETPOS, current / (progressboxmax / 30000), 0);
}
} else { else
{
SendMessage(progressboxbar, PBM_SETPOS, (current * 30000) / progressboxmax, 0); SendMessage(progressboxbar, PBM_SETPOS, (current * 30000) / progressboxmax, 0);
} // ENDIF- Our maximum # over 30000? (Avoiding divide-by-zero error) } // ENDIF- Our maximum # over 30000? (Avoiding divide-by-zero error)
if (progressboxmax >= 100)
{
if(progressboxmax >= 100) {
thispct = current / (progressboxmax / 100); thispct = current / (progressboxmax / 100);
if (thispct != progressboxlastpct)
if(thispct != progressboxlastpct) { {
sprintf(progressboxline, "%llu%% CDVDisoEFP Progress", thispct); sprintf(progressboxline, "%llu%% CDVDisoEFP Progress", thispct);
SetWindowText(progressboxwindow, progressboxline); SetWindowText(progressboxwindow, progressboxline);
progressboxlastpct = thispct; progressboxlastpct = thispct;
} // ENDIF- Change in percentage? (Avoiding title flicker) } // ENDIF- Change in percentage? (Avoiding title flicker)
} // ENDIF- Our maximum # over 100? (Avoiding divide-by-zero error) } // ENDIF- Our maximum # over 100? (Avoiding divide-by-zero error)
returnbool = PeekMessage(&msg, progressboxwindow, 0, 0, PM_REMOVE); returnbool = PeekMessage(&msg, progressboxwindow, 0, 0, PM_REMOVE);
while (returnbool != FALSE)
while(returnbool != FALSE) { {
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
returnbool = PeekMessage(&msg, progressboxwindow, 0, 0, PM_REMOVE); returnbool = PeekMessage(&msg, progressboxwindow, 0, 0, PM_REMOVE);
} // ENDWHILE- Updating the progress window display as needed } // ENDWHILE- Updating the progress window display as needed
return; return;
} // END ProgressBoxTick() } // END ProgressBoxTick()
void ProgressBoxStop()
{
void ProgressBoxStop() {
ShowWindow(progressboxwindow, SW_HIDE); ShowWindow(progressboxwindow, SW_HIDE);
SetWindowText(progressboxwindow, "CDVDisoEFP Progress"); SetWindowText(progressboxwindow, "CDVDisoEFP Progress");
return; return;
} // END ProgressBoxStop() } // END ProgressBoxStop()
void ProgressBoxCancelEvent()
{
void ProgressBoxCancelEvent() {
progressboxstop = 1; progressboxstop = 1;
return; return;
} // END ProgressBoxCancelEvent() } // END ProgressBoxCancelEvent()
BOOL CALLBACK ProgressBoxCallback(HWND window, BOOL CALLBACK ProgressBoxCallback(HWND window,
UINT msg, UINT msg,
WPARAM param, WPARAM param,
LPARAM param2)
LPARAM param2) { {
switch (msg)
switch(msg) { {
case WM_INITDIALOG: case WM_INITDIALOG:
return(TRUE); return(TRUE);
break; break;
case WM_CLOSE: // The "X" in the upper right corner is hit. case WM_CLOSE: // The "X" in the upper right corner is hit.
ProgressBoxCancelEvent(); ProgressBoxCancelEvent();
return(TRUE); return(TRUE);
break; break;
case WM_COMMAND: case WM_COMMAND:
switch (LOWORD(param))
switch(LOWORD(param)) { {
case IDC_0504: case IDC_0504:
ProgressBoxCancelEvent(); ProgressBoxCancelEvent();
return(TRUE); return(TRUE);
break; break;
} // ENDSWITCH param- Which item got the message? } // ENDSWITCH param- Which item got the message?
// Hmm. Custom control? (for WM_GETFONT and WM_SETFONT msgs?) // Hmm. Custom control? (for WM_GETFONT and WM_SETFONT msgs?)
} // ENDSWITCH msg- what message has been sent to this window? } // ENDSWITCH msg- what message has been sent to this window?
return(FALSE); // Not a recognized message? Tell Windows to handle it. return(FALSE); // Not a recognized message? Tell Windows to handle it.
} // ENDIF ProgressBoxCallback() } // ENDIF ProgressBoxCallback()
void ProgressBoxDisplay()
{
void ProgressBoxDisplay() {
// ? progressload // ? progressload
LPARAM range; LPARAM range;
InitCommonControls(); InitCommonControls();
// progressload. // progressload.
// progressload. = ICC_PROGRESS_CLASS // progressload. = ICC_PROGRESS_CLASS
// InitCommonControlsEx(&progressload); // InitCommonControlsEx(&progressload);
progressboxwindow = CreateDialog(progmodule, progressboxwindow = CreateDialog(progmodule,
MAKEINTRESOURCE(DLG_0500), MAKEINTRESOURCE(DLG_0500),
mainboxwindow, mainboxwindow,
(DLGPROC) ProgressBoxCallback); (DLGPROC) ProgressBoxCallback);
progressboxbar = GetDlgItem(progressboxwindow, IDC_0502); progressboxbar = GetDlgItem(progressboxwindow, IDC_0502);
range = MAKELPARAM(0, 30000); // Widen the range for granularity range = MAKELPARAM(0, 30000); // Widen the range for granularity
SendMessage(progressboxbar, PBM_SETRANGE, 0, range); SendMessage(progressboxbar, PBM_SETRANGE, 0, range);
ShowWindow(progressboxwindow, SW_SHOWNORMAL); ShowWindow(progressboxwindow, SW_SHOWNORMAL);
ShowWindow(progressboxwindow, SW_HIDE); ShowWindow(progressboxwindow, SW_HIDE);
return; return;
} // END ProgressBoxDisplay() } // END ProgressBoxDisplay()

View File

@ -1,76 +1,38 @@
/* progressbox.h /* progressbox.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef PROGRESSBOX_H #ifndef PROGRESSBOX_H
#define PROGRESSBOX_H #define PROGRESSBOX_H
#include <windows.h> #include <windows.h>
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
#include "PS2Etypes.h" #include "PS2Etypes.h"
extern const char *compressnames[]; extern const char *compressnames[];
extern HWND progressboxwindow; extern HWND progressboxwindow;
extern int progressboxstop; extern int progressboxstop;
extern void ProgressBoxStart(char *description, off64_t maximum); extern void ProgressBoxStart(char *description, off64_t maximum);
extern void ProgressBoxTick(off64_t current); extern void ProgressBoxTick(off64_t current);
@ -82,8 +44,5 @@ extern void ProgressBoxDestroy();
extern void ProgressBoxDisplay(); extern void ProgressBoxDisplay();
#endif /* MAINBOX_H */ #endif /* MAINBOX_H */

View File

@ -1,74 +1,37 @@
/* Weditres generated include file. Do NOT edit */ /* Weditres generated include file. Do NOT edit */
#include <windows.h> #include <windows.h>
#define DLG_0100 100 #define DLG_0100 100
#define IDC_0104 104 #define IDC_0104 104
#define DLG_0200 200 #define DLG_0200 200
#define IDC_0202 202 #define IDC_0202 202
#define IDC_0203 203 #define IDC_0203 203
#define IDC_0204 204 #define IDC_0204 204
#define IDC_0205 205 #define IDC_0205 205
#define IDC_0206 206 #define IDC_0206 206
#define IDC_0207 207 #define IDC_0207 207
#define IDC_0208 208 #define IDC_0208 208
#define IDC_0209 209 #define IDC_0209 209
#define IDC_0210 210 #define IDC_0210 210
#define DLG_0300 300 #define DLG_0300 300
#define IDC_0302 302 #define IDC_0302 302
#define IDC_0303 303 #define IDC_0303 303
#define IDC_0305 305 #define IDC_0305 305
#define IDC_0306 306 #define IDC_0306 306
#define IDC_0307 307 #define IDC_0307 307
#define IDC_0309 309 #define IDC_0309 309
#define IDC_0311 311 #define IDC_0311 311
#define IDC_0312 312 #define IDC_0312 312
#define IDC_0313 313 #define IDC_0313 313
#define DLG_0400 400 #define DLG_0400 400
#define IDC_0402 402 #define IDC_0402 402
#define IDC_0403 403 #define IDC_0403 403
#define IDC_0404 404 #define IDC_0404 404
#define IDC_0406 406 #define IDC_0406 406
#define IDC_0408 408 #define IDC_0408 408
#define IDC_0409 409 #define IDC_0409 409
#define IDC_0410 410 #define IDC_0410 410
#define DLG_0500 500 #define DLG_0500 500
#define IDC_0501 501 #define IDC_0501 501
#define IDC_0502 502 #define IDC_0502 502
#define IDC_0503 503 #define IDC_0503 503
#define IDC_0504 504 #define IDC_0504 504

View File

@ -1,374 +1,199 @@
/* tablerebuild.c /* tablerebuild.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <stdio.h> // sprintf() #include <stdio.h> // sprintf()
#include <stdlib.h> // malloc() #include <stdlib.h> // malloc()
#include "mainbox.h" #include "mainbox.h"
#include "progressbox.h" #include "progressbox.h"
#include "isofile.h" #include "isofile.h"
#include "multifile.h" #include "multifile.h"
#include "isocompress.h" // CompressClose() #include "isocompress.h" // CompressClose()
#include "gzipv1.h" #include "gzipv1.h"
#include "gzipv2.h" #include "gzipv2.h"
#include "bzip2v2.h" #include "bzip2v2.h"
#include "bzip2v3.h" #include "bzip2v3.h"
#include "actualfile.h" // ACTUALHANDLENULL #include "actualfile.h" // ACTUALHANDLENULL
void IsoTableRebuild(const char *filename)
{
void IsoTableRebuild(const char *filename) {
struct IsoFile *datafile; struct IsoFile *datafile;
struct IsoFile *tablefile; struct IsoFile *tablefile;
int retval; int retval;
char tempblock[65536]; char tempblock[65536];
int stop; int stop;
struct TableData table; struct TableData table;
datafile = IsoFileOpenForRead(filename); datafile = IsoFileOpenForRead(filename);
// Note: This is the start of the "Multifile" process. It's commented // Note: This is the start of the "Multifile" process. It's commented
// out so at least we can rebuild 1 part of a multifile at a time. // out so at least we can rebuild 1 part of a multifile at a time.
// IsoNameStripExt(datafile); // IsoNameStripExt(datafile);
// IsoNameStripMulti(datafile); // IsoNameStripMulti(datafile);
// Prep tablefile to hold ONLY a table (no data) // Prep tablefile to hold ONLY a table (no data)
tablefile = (struct IsoFile *) malloc(sizeof(struct IsoFile)); tablefile = (struct IsoFile *) malloc(sizeof(struct IsoFile));
if (tablefile == NULL)
if(tablefile == NULL) { {
datafile = IsoFileClose(datafile); datafile = IsoFileClose(datafile);
return; return;
} // ENDIF- Failed to allocate? Abort. } // ENDIF- Failed to allocate? Abort.
tablefile->sectorpos = 0; tablefile->sectorpos = 0;
tablefile->openforread = 0; tablefile->openforread = 0;
tablefile->filebytepos = 0; tablefile->filebytepos = 0;
tablefile->filebytesize = 0; tablefile->filebytesize = 0;
tablefile->filesectorpos = 0; tablefile->filesectorpos = 0;
tablefile->filesectorsize = 0; tablefile->filesectorsize = 0;
tablefile->handle = ACTUALHANDLENULL; tablefile->handle = ACTUALHANDLENULL;
tablefile->namepos = 0; tablefile->namepos = 0;
while ((tablefile->namepos < 255) && while ((tablefile->namepos < 255) &&
(*(filename + tablefile->namepos) != 0))
(*(filename + tablefile->namepos) != 0)) { {
tablefile->name[tablefile->namepos] = *(filename + tablefile->namepos); tablefile->name[tablefile->namepos] = *(filename + tablefile->namepos);
tablefile->namepos++; tablefile->namepos++;
} // ENDWHILE- Copying file name into tablefile } // ENDWHILE- Copying file name into tablefile
tablefile->name[tablefile->namepos] = 0; // And 0-terminate. tablefile->name[tablefile->namepos] = 0; // And 0-terminate.
tablefile->imageheader = datafile->imageheader; tablefile->imageheader = datafile->imageheader;
tablefile->blocksize = datafile->blocksize; tablefile->blocksize = datafile->blocksize;
tablefile->blockoffset = datafile->blockoffset; tablefile->blockoffset = datafile->blockoffset;
tablefile->cdvdtype = 0; // Not important right now. tablefile->cdvdtype = 0; // Not important right now.
tablefile->compress = datafile->compress; tablefile->compress = datafile->compress;
tablefile->compresspos = datafile->compresspos; tablefile->compresspos = datafile->compresspos;
tablefile->numsectors = datafile->numsectors; tablefile->numsectors = datafile->numsectors;
tablefile->tabledata = NULL; tablefile->tabledata = NULL;
switch (tablefile->compress)
{
switch(tablefile->compress) {
case 1: case 1:
retval = GZipV1OpenTableForWrite(tablefile); retval = GZipV1OpenTableForWrite(tablefile);
break; break;
case 2: case 2:
retval = -1; retval = -1;
break; break;
case 3: case 3:
retval = GZipV2OpenTableForWrite(tablefile); retval = GZipV2OpenTableForWrite(tablefile);
break; break;
case 4: case 4:
retval = BZip2V2OpenTableForWrite(tablefile); retval = BZip2V2OpenTableForWrite(tablefile);
break; break;
case 5: case 5:
retval = BZip2V3OpenTableForWrite(tablefile); retval = BZip2V3OpenTableForWrite(tablefile);
break; break;
default: default:
retval = -1; retval = -1;
break; break;
} // ENDSWITCH compress- Which table are we writing out? } // ENDSWITCH compress- Which table are we writing out?
if (retval < 0)
if(retval < 0) { {
datafile = IsoFileClose(datafile); datafile = IsoFileClose(datafile);
return; return;
} // ENDIF- Failed to open table file? Abort } // ENDIF- Failed to open table file? Abort
sprintf(tempblock, "Rebuilding table for %s", datafile->name); sprintf(tempblock, "Rebuilding table for %s", datafile->name);
ProgressBoxStart(tempblock, datafile->filebytesize); ProgressBoxStart(tempblock, datafile->filebytesize);
stop = 0; stop = 0;
mainboxstop = 0; mainboxstop = 0;
progressboxstop = 0; progressboxstop = 0;
while ((stop == 0) && (datafile->filebytepos < datafile->filebytesize))
while((stop == 0) && (datafile->filebytepos < datafile->filebytesize)) { {
switch (datafile->compress)
switch(datafile->compress) { {
case 1: case 1:
retval = GZipV1Read(datafile, 0, tempblock); retval = GZipV1Read(datafile, 0, tempblock);
break; break;
case 2: case 2:
retval = -1; retval = -1;
break; break;
case 3: case 3:
retval = GZipV2Read(datafile, 0, tempblock); retval = GZipV2Read(datafile, 0, tempblock);
break; break;
case 4: case 4:
retval = BZip2V2Read(datafile, 0, tempblock); retval = BZip2V2Read(datafile, 0, tempblock);
break; break;
case 5: case 5:
retval = BZip2V3Read(datafile, 0, tempblock); retval = BZip2V3Read(datafile, 0, tempblock);
break; break;
default: default:
retval = -1; retval = -1;
break; break;
} // ENDSWITCH compress- Scanning for the next complete compressed block } // ENDSWITCH compress- Scanning for the next complete compressed block
if (retval <= 0)
{
if(retval <= 0) {
#ifdef FUNCTION_WARNING_TABLEREBUILD #ifdef FUNCTION_WARNING_TABLEREBUILD
PrintLog("CDVDiso rebuild: failed to decompress - data corrupt"); PrintLog("CDVDiso rebuild: failed to decompress - data corrupt");
#endif /* FUNCTION_WARNING_TABLEREBUILD */ #endif /* FUNCTION_WARNING_TABLEREBUILD */
stop = 1; stop = 1;
}
} else { else
{
table.offset = datafile->filebytepos - retval; table.offset = datafile->filebytepos - retval;
table.size = retval; table.size = retval;
switch (tablefile->compress)
switch(tablefile->compress) { {
case 1: case 1:
retval = GZipV1WriteTable(tablefile, table); retval = GZipV1WriteTable(tablefile, table);
break; break;
case 2: case 2:
retval = -1; retval = -1;
break; break;
case 3: case 3:
retval = GZipV2WriteTable(tablefile, table); retval = GZipV2WriteTable(tablefile, table);
break; break;
case 4: case 4:
retval = BZip2V2WriteTable(tablefile, table); retval = BZip2V2WriteTable(tablefile, table);
break; break;
case 5: case 5:
retval = BZip2V3WriteTable(tablefile, table); retval = BZip2V3WriteTable(tablefile, table);
break; break;
default: default:
retval = -1; retval = -1;
break; break;
} // ENDSWITCH compress- Writing out the relavent table facts } // ENDSWITCH compress- Writing out the relavent table facts
if (retval < 0) stop = 1; if (retval < 0) stop = 1;
} // ENDIF- Do we have a valid record to write an entry for? } // ENDIF- Do we have a valid record to write an entry for?
ProgressBoxTick(datafile->filebytepos); ProgressBoxTick(datafile->filebytepos);
if (mainboxstop != 0) stop = 2; if (mainboxstop != 0) stop = 2;
if (progressboxstop != 0) stop = 2; if (progressboxstop != 0) stop = 2;
} // ENDWHILE- Read in the data file and writing a table, 1 block at a time } // ENDWHILE- Read in the data file and writing a table, 1 block at a time
ProgressBoxStop(); ProgressBoxStop();
CompressClose(tablefile); // Guarentee the table is flushed and closed. CompressClose(tablefile); // Guarentee the table is flushed and closed.
if (stop != 0)
if(stop != 0) { {
ActualFileDelete(tablefile->tablename); ActualFileDelete(tablefile->tablename);
} // ENDIF- Aborted or trouble? Delete the table file } // ENDIF- Aborted or trouble? Delete the table file
tablefile = IsoFileClose(tablefile); tablefile = IsoFileClose(tablefile);
datafile = IsoFileClose(datafile); datafile = IsoFileClose(datafile);
return; return;
} // END IsoTableRebuild() } // END IsoTableRebuild()

View File

@ -1,64 +1,28 @@
/* tablerebuild.h /* tablerebuild.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef TABLEREBUILD_H #ifndef TABLEREBUILD_H
#define TABLEREBUILD_H #define TABLEREBUILD_H
// #define FUNCTION_WARNING_TABLEREBUILD // #define FUNCTION_WARNING_TABLEREBUILD
extern void IsoTableRebuild(const char *filename); extern void IsoTableRebuild(const char *filename);
#endif /* TABLEREBUILD_H */ #endif /* TABLEREBUILD_H */

View File

@ -1,612 +1,308 @@
/* blockv2.c /* blockv2.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <stdlib.h> // malloc() #include <stdlib.h> // malloc()
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
#include "zlib/zlib.h" #include "zlib/zlib.h"
#include "convert.h" #include "convert.h"
#include "logfile.h" #include "logfile.h"
#include "isofile.h" // IsoFile #include "isofile.h" // IsoFile
#include "isocompress.h" // TableData, TableMap #include "isocompress.h" // TableData, TableMap
#include "actualfile.h" #include "actualfile.h"
#include "blockv2.h" #include "blockv2.h"
#ifdef _WIN32 #ifdef _WIN32
#pragma pack(1) #pragma pack(1)
#endif /* _WIN32 */ #endif /* _WIN32 */
struct BlockV2Header
{
struct BlockV2Header {
char id[4]; char id[4];
unsigned int blocksize; unsigned int blocksize;
unsigned int numblocks; unsigned int numblocks;
unsigned int blockoffset; unsigned int blockoffset;
#ifdef _WIN32 #ifdef _WIN32
}; };
#else #else
} __attribute__((packed)); } __attribute__((packed));
#endif /* _WIN32 */ #endif /* _WIN32 */
#ifdef _WIN32 #ifdef _WIN32
#pragma pack() #pragma pack()
#endif /* _WIN32 */ #endif /* _WIN32 */
int BlockV2OpenTableForRead(struct IsoFile *isofile)
{
int BlockV2OpenTableForRead(struct IsoFile *isofile) {
int i; int i;
int j; int j;
off64_t offset; off64_t offset;
int tableoffset; int tableoffset;
int retval; int retval;
union TableMap tablemap; union TableMap tablemap;
#ifdef VERBOSE_FUNCTION_BLOCKV2 #ifdef VERBOSE_FUNCTION_BLOCKV2
PrintLog("CDVDiso BlockV2: OpenTableForRead()"); PrintLog("CDVDiso BlockV2: OpenTableForRead()");
#endif /* VERBOSE_FUNCTION_BLOCKV2 */ #endif /* VERBOSE_FUNCTION_BLOCKV2 */
// We pre-read the WHOLE offset table. // We pre-read the WHOLE offset table.
isofile->tabledata = (char *) malloc(isofile->filesectorsize * sizeof(struct TableData)); isofile->tabledata = (char *) malloc(isofile->filesectorsize * sizeof(struct TableData));
if (isofile->tabledata == NULL)
if(isofile->tabledata == NULL) { {
#ifdef VERBOSE_WARNING_BLOCKV2 #ifdef VERBOSE_WARNING_BLOCKV2
PrintLog("CDVDiso BlockV2: Couldn't allocate internal table!"); PrintLog("CDVDiso BlockV2: Couldn't allocate internal table!");
#endif /* VERBOSE_WARNING_BLOCKV2 */ #endif /* VERBOSE_WARNING_BLOCKV2 */
return(-1); return(-1);
} // ENDIF- Could not get enough memory to hold table data } // ENDIF- Could not get enough memory to hold table data
offset = sizeof(struct BlockV2Header); offset = sizeof(struct BlockV2Header);
tableoffset = 0; tableoffset = 0;
for (i = 0; i < isofile->filesectorsize; i++)
for(i = 0; i < isofile->filesectorsize; i++) { {
retval = BlockV2Seek(isofile, offset); retval = BlockV2Seek(isofile, offset);
if (retval != 0)
if(retval != 0) { {
#ifdef VERBOSE_WARNING_BLOCKV2 #ifdef VERBOSE_WARNING_BLOCKV2
PrintLog("CDVDiso BlockV2: Failed to find sector %i!", i); PrintLog("CDVDiso BlockV2: Failed to find sector %i!", i);
#endif /* VERBOSE_WARNING_BLOCKV2 */ #endif /* VERBOSE_WARNING_BLOCKV2 */
return(-1); return(-1);
} // ENDIF- Trouble finding a lsn id? Fail. } // ENDIF- Trouble finding a lsn id? Fail.
retval = ActualFileRead(isofile->handle, retval = ActualFileRead(isofile->handle,
sizeof(int), sizeof(int),
(char *) & j); (char *) & j);
if (retval != sizeof(int))
if(retval != sizeof(int)) { {
#ifdef VERBOSE_WARNING_BLOCKV2 #ifdef VERBOSE_WARNING_BLOCKV2
PrintLog("CDVDiso BlockV2: Failed to read in sector %i!", i); PrintLog("CDVDiso BlockV2: Failed to read in sector %i!", i);
#endif /* VERBOSE_WARNING_BLOCKV2 */ #endif /* VERBOSE_WARNING_BLOCKV2 */
return(-1); return(-1);
} // ENDIF- Trouble reading in a lsn id? Table damaged... fail. } // ENDIF- Trouble reading in a lsn id? Table damaged... fail.
tablemap.table.offset = ConvertEndianUInt(j); // Actually, a lsn. tablemap.table.offset = ConvertEndianUInt(j); // Actually, a lsn.
for (j = 0; j < sizeof(struct TableData); j++) for (j = 0; j < sizeof(struct TableData); j++)
*(isofile->tabledata + tableoffset + j) = tablemap.ch[j]; *(isofile->tabledata + tableoffset + j) = tablemap.ch[j];
offset += isofile->blocksize + 4; offset += isofile->blocksize + 4;
tableoffset += sizeof(struct TableData); tableoffset += sizeof(struct TableData);
} // NEXT i- reading in the sizes, and making offset as I go. } // NEXT i- reading in the sizes, and making offset as I go.
isofile->tablehandle = ACTUALHANDLENULL; isofile->tablehandle = ACTUALHANDLENULL;
return(0); return(0);
} // END BlockV2OpenTableForRead() } // END BlockV2OpenTableForRead()
int BlockV2SeekTable(struct IsoFile *isofile, off64_t sector)
{
int BlockV2SeekTable(struct IsoFile *isofile, off64_t sector) {
int i; int i;
int tableoffset; int tableoffset;
union TableMap tablemap; union TableMap tablemap;
off64_t filesectorstart; off64_t filesectorstart;
#ifdef VERBOSE_FUNCTION_BLOCKV2 #ifdef VERBOSE_FUNCTION_BLOCKV2
PrintLog("CDVDiso BlockV2: SeekTable(%lli)", sector); PrintLog("CDVDiso BlockV2: SeekTable(%lli)", sector);
#endif /* VERBOSE_FUNCTION_BLOCKV2 */ #endif /* VERBOSE_FUNCTION_BLOCKV2 */
if ((isofile->filesectorpos >= 0) && if ((isofile->filesectorpos >= 0) &&
(isofile->filesectorpos < isofile->filesectorsize))
(isofile->filesectorpos < isofile->filesectorsize)) { {
tableoffset = isofile->filesectorpos * sizeof(struct TableData); tableoffset = isofile->filesectorpos * sizeof(struct TableData);
for (i = 0; i < sizeof(struct TableData); i++) for (i = 0; i < sizeof(struct TableData); i++)
tablemap.ch[i] = *(isofile->tabledata + tableoffset + i); tablemap.ch[i] = *(isofile->tabledata + tableoffset + i);
if (sector == tablemap.table.offset)
if(sector == tablemap.table.offset) { {
return(0); return(0);
} // ENDIF- Are we already pointing at the right sector? } // ENDIF- Are we already pointing at the right sector?
}
else
} else { {
isofile->filesectorpos = 0; isofile->filesectorpos = 0;
tablemap.table.offset = -1; tablemap.table.offset = -1;
} // ENDIF- Is the file sector pointer within table limits? } // ENDIF- Is the file sector pointer within table limits?
filesectorstart = isofile->filesectorpos; filesectorstart = isofile->filesectorpos;
isofile->filesectorpos++; isofile->filesectorpos++;
if (isofile->filesectorpos >= isofile->filesectorsize) if (isofile->filesectorpos >= isofile->filesectorsize)
isofile->filesectorpos = 0; isofile->filesectorpos = 0;
while ((isofile->filesectorpos != filesectorstart) && while ((isofile->filesectorpos != filesectorstart) &&
(tablemap.table.offset != sector))
(tablemap.table.offset != sector)) { {
tableoffset = isofile->filesectorpos * sizeof(struct TableData); tableoffset = isofile->filesectorpos * sizeof(struct TableData);
for (i = 0; i < sizeof(struct TableData); i++) for (i = 0; i < sizeof(struct TableData); i++)
tablemap.ch[i] = *(isofile->tabledata + tableoffset + i); tablemap.ch[i] = *(isofile->tabledata + tableoffset + i);
if (tablemap.table.offset != sector)
{
if(tablemap.table.offset != sector) {
isofile->filesectorpos++; isofile->filesectorpos++;
if (isofile->filesectorpos >= isofile->filesectorsize) if (isofile->filesectorpos >= isofile->filesectorsize)
isofile->filesectorpos = 0; isofile->filesectorpos = 0;
} // ENDIF- Still didn't find it? move to next sector. } // ENDIF- Still didn't find it? move to next sector.
} // ENDWHILE- Scanning through whole sector list (starting at current pos) } // ENDWHILE- Scanning through whole sector list (starting at current pos)
if (isofile->filesectorpos == filesectorstart)
{
if(isofile->filesectorpos == filesectorstart) {
return(-1); return(-1);
} // ENDIF- Did we loop through the whole file... and not find this sector? } // ENDIF- Did we loop through the whole file... and not find this sector?
return(0); return(0);
} // END BlockV2SeekTable() } // END BlockV2SeekTable()
int BlockV2ReadTable(struct IsoFile *isofile, struct TableData *table)
{
int BlockV2ReadTable(struct IsoFile *isofile, struct TableData *table) {
#ifdef VERBOSE_FUNCTION_BLOCKV2 #ifdef VERBOSE_FUNCTION_BLOCKV2
PrintLog("CDVDiso BlockV2: ReadTable()"); PrintLog("CDVDiso BlockV2: ReadTable()");
#endif /* VERBOSE_FUNCTION_BLOCKV2 */ #endif /* VERBOSE_FUNCTION_BLOCKV2 */
table->offset = sizeof(int) + isofile->blocksize; table->offset = sizeof(int) + isofile->blocksize;
table->offset *= isofile->filesectorpos; table->offset *= isofile->filesectorpos;
table->offset += sizeof(struct BlockV2Header) + 4; table->offset += sizeof(struct BlockV2Header) + 4;
table->size = isofile->blocksize; table->size = isofile->blocksize;
isofile->filesectorpos++; isofile->filesectorpos++;
return(0); return(0);
} // END BlockV2ReadTable() } // END BlockV2ReadTable()
int BlockV2OpenTableForWrite(struct IsoFile *isofile)
{
int BlockV2OpenTableForWrite(struct IsoFile *isofile) {
return(-1); return(-1);
} // END BlockV2OpenTableForWrite() } // END BlockV2OpenTableForWrite()
int BlockV2WriteTable(struct IsoFile *isofile, struct TableData table)
{
int BlockV2WriteTable(struct IsoFile *isofile, struct TableData table) {
return(-1); return(-1);
} // END BlockV2WriteTable() } // END BlockV2WriteTable()
int BlockV2OpenForRead(struct IsoFile *isofile)
{
int BlockV2OpenForRead(struct IsoFile *isofile) {
int retval; int retval;
struct BlockV2Header header; struct BlockV2Header header;
#ifdef VERBOSE_FUNCTION_BLOCKV2 #ifdef VERBOSE_FUNCTION_BLOCKV2
PrintLog("CDVDiso BlockV2: OpenForRead()"); PrintLog("CDVDiso BlockV2: OpenForRead()");
#endif /* VERBOSE_FUNCTION_BLOCKV2 */ #endif /* VERBOSE_FUNCTION_BLOCKV2 */
isofile->handle = ActualFileOpenForRead(isofile->name); isofile->handle = ActualFileOpenForRead(isofile->name);
if (isofile->handle == ACTUALHANDLENULL)
if(isofile->handle == ACTUALHANDLENULL) { {
return(-1); return(-1);
} // ENDIF- Couldn't open data file? Fail. } // ENDIF- Couldn't open data file? Fail.
isofile->filebytesize = ActualFileSize(isofile->handle); isofile->filebytesize = ActualFileSize(isofile->handle);
isofile->filebytepos = 0; isofile->filebytepos = 0;
isofile->imageheader = 0; isofile->imageheader = 0;
isofile->numsectors = 1; // Sectors per block isofile->numsectors = 1; // Sectors per block
retval = ActualFileRead(isofile->handle, retval = ActualFileRead(isofile->handle,
sizeof(struct BlockV2Header), sizeof(struct BlockV2Header),
(char *) & header); (char *) & header);
if (retval != sizeof(struct BlockV2Header))
if(retval != sizeof(struct BlockV2Header)) { {
#ifdef VERBOSE_WARNING_BLOCKV2 #ifdef VERBOSE_WARNING_BLOCKV2
PrintLog("CDVDiso BlockV2: Couldn't read header!"); PrintLog("CDVDiso BlockV2: Couldn't read header!");
#endif /* VERBOSE_WARNING_BLOCKV2 */ #endif /* VERBOSE_WARNING_BLOCKV2 */
ActualFileClose(isofile->handle); ActualFileClose(isofile->handle);
isofile->handle = ACTUALHANDLENULL; isofile->handle = ACTUALHANDLENULL;
return(-1); return(-1);
} // ENDIF Could not read the first sector? Fail. } // ENDIF Could not read the first sector? Fail.
isofile->filebytepos += retval; isofile->filebytepos += retval;
if ((header.id[0] != 'B') || if ((header.id[0] != 'B') ||
(header.id[1] != 'D') || (header.id[1] != 'D') ||
(header.id[2] != 'V') || (header.id[2] != 'V') ||
(header.id[3] != '2'))
(header.id[3] != '2')) { {
#ifdef VERBOSE_WARNING_BLOCKV2 #ifdef VERBOSE_WARNING_BLOCKV2
PrintLog("CDVDiso BlockV2: Not a block dump v2 header!"); PrintLog("CDVDiso BlockV2: Not a block dump v2 header!");
#endif /* VERBOSE_WARNING_BLOCKV2 */ #endif /* VERBOSE_WARNING_BLOCKV2 */
ActualFileClose(isofile->handle); ActualFileClose(isofile->handle);
isofile->handle = ACTUALHANDLENULL; isofile->handle = ACTUALHANDLENULL;
return(-1); return(-1);
} // ENDIF- ID for this compression type doesn't match? } // ENDIF- ID for this compression type doesn't match?
isofile->blocksize = ConvertEndianUInt(header.blocksize); isofile->blocksize = ConvertEndianUInt(header.blocksize);
// isofile->filesectorsize = ConvertEndianUInt(header.numblocks); // isofile->filesectorsize = ConvertEndianUInt(header.numblocks);
isofile->blockoffset = ConvertEndianUInt(header.blockoffset); isofile->blockoffset = ConvertEndianUInt(header.blockoffset);
isofile->filesectorsize = isofile->filebytesize; isofile->filesectorsize = isofile->filebytesize;
isofile->filesectorsize -= 16; isofile->filesectorsize -= 16;
isofile->filesectorsize /= (isofile->blocksize + sizeof(int)); isofile->filesectorsize /= (isofile->blocksize + sizeof(int));
isofile->filesectorpos = 0; isofile->filesectorpos = 0;
return(0); return(0);
} // END BlockV2OpenForRead() } // END BlockV2OpenForRead()
int BlockV2Seek(struct IsoFile *isofile, off64_t position)
{
int BlockV2Seek(struct IsoFile *isofile, off64_t position) {
int retval; int retval;
#ifdef VERBOSE_FUNCTION_BLOCKV2 #ifdef VERBOSE_FUNCTION_BLOCKV2
PrintLog("CDVDiso BlockV2: Seek(%lli)", position); PrintLog("CDVDiso BlockV2: Seek(%lli)", position);
#endif /* VERBOSE_FUNCTION_BLOCKV2 */ #endif /* VERBOSE_FUNCTION_BLOCKV2 */
retval = ActualFileSeek(isofile->handle, position); retval = ActualFileSeek(isofile->handle, position);
if (retval < 0)
if(retval < 0) { {
#ifdef VERBOSE_WARNING_BLOCKV2 #ifdef VERBOSE_WARNING_BLOCKV2
PrintLog("CDVDiso BlockV2: Couldn't find the start of the block!"); PrintLog("CDVDiso BlockV2: Couldn't find the start of the block!");
#endif /* VERBOSE_WARNING_BLOCKV2 */ #endif /* VERBOSE_WARNING_BLOCKV2 */
return(-1); return(-1);
} // ENDIF- Couldn't find the data entry? Fail. } // ENDIF- Couldn't find the data entry? Fail.
isofile->filebytepos = position; isofile->filebytepos = position;
return(0); return(0);
return(-1); // Fail. (Due to lack of ambition?) return(-1); // Fail. (Due to lack of ambition?)
} // END BlockV2Seek() } // END BlockV2Seek()
int BlockV2Read(struct IsoFile *isofile, int bytes, char *buffer)
{
int BlockV2Read(struct IsoFile *isofile, int bytes, char *buffer) {
int retval; int retval;
#ifdef VERBOSE_FUNCTION_BLOCKV2 #ifdef VERBOSE_FUNCTION_BLOCKV2
PrintLog("CDVDiso BlockV2: Read(%i)", bytes); PrintLog("CDVDiso BlockV2: Read(%i)", bytes);
#endif /* VERBOSE_FUNCTION_BLOCKV2 */ #endif /* VERBOSE_FUNCTION_BLOCKV2 */
retval = ActualFileRead(isofile->handle, isofile->blocksize, buffer); retval = ActualFileRead(isofile->handle, isofile->blocksize, buffer);
if (retval > 0) isofile->filebytepos += retval; if (retval > 0) isofile->filebytepos += retval;
if (retval != isofile->blocksize)
if(retval != isofile->blocksize) { {
#ifdef VERBOSE_WARNING_BLOCKV2 #ifdef VERBOSE_WARNING_BLOCKV2
PrintLog("CDVDiso BlockV2: Cannot read bytes! Returned: (%i)", retval); PrintLog("CDVDiso BlockV2: Cannot read bytes! Returned: (%i)", retval);
#endif /* VERBOSE_WARNING_BLOCKV2 */ #endif /* VERBOSE_WARNING_BLOCKV2 */
return(-1); return(-1);
} // ENDIF- Trouble reading compressed sector? Abort. } // ENDIF- Trouble reading compressed sector? Abort.
return(isofile->blocksize); return(isofile->blocksize);
} // END BlockV2Read() } // END BlockV2Read()
int BlockV2OpenForWrite(struct IsoFile *isofile)
{
int BlockV2OpenForWrite(struct IsoFile *isofile) {
return(-1); return(-1);
} // END BlockV2OpenForWrite() } // END BlockV2OpenForWrite()
int BlockV2Write(struct IsoFile *isofile, char *buffer)
{
int BlockV2Write(struct IsoFile *isofile, char *buffer) {
return(-1); return(-1);
} // END BlockV2Write() } // END BlockV2Write()
void BlockV2Close(struct IsoFile *isofile)
{
void BlockV2Close(struct IsoFile *isofile) {
#ifdef VERBOSE_FUNCTION_BLOCKV2 #ifdef VERBOSE_FUNCTION_BLOCKV2
PrintLog("CDVDiso BlockV2: Close()"); PrintLog("CDVDiso BlockV2: Close()");
#endif /* VERBOSE_FUNCTION_BLOCKV2 */ #endif /* VERBOSE_FUNCTION_BLOCKV2 */
if (isofile->handle != ACTUALHANDLENULL)
{
if(isofile->handle != ACTUALHANDLENULL) {
ActualFileClose(isofile->handle); ActualFileClose(isofile->handle);
isofile->handle = ACTUALHANDLENULL; isofile->handle = ACTUALHANDLENULL;
} // ENDIF- Is there a data file open? Close it. } // ENDIF- Is there a data file open? Close it.
if (isofile->tabledata != NULL)
{
if(isofile->tabledata != NULL) {
free(isofile->tabledata); free(isofile->tabledata);
isofile->tabledata = NULL; isofile->tabledata = NULL;
} // ENDIF- Do we have a read-in table to clear out? } // ENDIF- Do we have a read-in table to clear out?
return; return;
} // END BlockV2Close() } // END BlockV2Close()

View File

@ -1,104 +1,46 @@
/* blockv2.h /* blockv2.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef BLOCKV2_H #ifndef BLOCKV2_H
#define BLOCKV2_H #define BLOCKV2_H
#include <sys/types.h> #include <sys/types.h>
#include "isofile.h" #include "isofile.h"
#include "isocompress.h" #include "isocompress.h"
// #define VERBOSE_FUNCTION_BLOCKV2 // #define VERBOSE_FUNCTION_BLOCKV2
// #define VERBOSE_WARNING_BLOCKV2 // #define VERBOSE_WARNING_BLOCKV2
extern int BlockV2OpenTableForRead(struct IsoFile *isofile); extern int BlockV2OpenTableForRead(struct IsoFile *isofile);
extern int BlockV2SeekTable(struct IsoFile *isofile, off64_t sector); extern int BlockV2SeekTable(struct IsoFile *isofile, off64_t sector);
extern int BlockV2ReadTable(struct IsoFile *isofile, struct TableData *table); extern int BlockV2ReadTable(struct IsoFile *isofile, struct TableData *table);
extern int BlockV2OpenTableForWrite(struct IsoFile *isofile); extern int BlockV2OpenTableForWrite(struct IsoFile *isofile);
extern int BlockV2WriteTable(struct IsoFile *isofile, struct TableData table); extern int BlockV2WriteTable(struct IsoFile *isofile, struct TableData table);
extern int BlockV2OpenForRead(struct IsoFile *isofile); extern int BlockV2OpenForRead(struct IsoFile *isofile);
extern int BlockV2Seek(struct IsoFile *isofile, off64_t sector); extern int BlockV2Seek(struct IsoFile *isofile, off64_t sector);
extern int BlockV2Read(struct IsoFile *isofile, int bytes, char *buffer); extern int BlockV2Read(struct IsoFile *isofile, int bytes, char *buffer);
extern void BlockV2Close(struct IsoFile *isofile); extern void BlockV2Close(struct IsoFile *isofile);
extern int BlockV2OpenForWrite(struct IsoFile *isofile); extern int BlockV2OpenForWrite(struct IsoFile *isofile);
extern int BlockV2Write(struct IsoFile *isofile, char *buffer); extern int BlockV2Write(struct IsoFile *isofile, char *buffer);
#endif /* BLOCKV2_H */ #endif /* BLOCKV2_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,104 +1,46 @@
/* bzip2v2.h /* bzip2v2.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef BZIP2V2_H #ifndef BZIP2V2_H
#define BZIP2V2_H #define BZIP2V2_H
#include <sys/types.h> #include <sys/types.h>
#include "isofile.h" #include "isofile.h"
#include "isocompress.h" #include "isocompress.h"
// #define VERBOSE_FUNCTION_BZIP2V2 // #define VERBOSE_FUNCTION_BZIP2V2
// #define VERBOSE_WARNING_BZIP2V2 // #define VERBOSE_WARNING_BZIP2V2
extern int BZip2V2OpenTableForRead(struct IsoFile *isofile); extern int BZip2V2OpenTableForRead(struct IsoFile *isofile);
extern int BZip2V2SeekTable(struct IsoFile *isofile, off64_t sector); extern int BZip2V2SeekTable(struct IsoFile *isofile, off64_t sector);
extern int BZip2V2ReadTable(struct IsoFile *isofile, struct TableData *table); extern int BZip2V2ReadTable(struct IsoFile *isofile, struct TableData *table);
extern int BZip2V2OpenTableForWrite(struct IsoFile *isofile); extern int BZip2V2OpenTableForWrite(struct IsoFile *isofile);
extern int BZip2V2WriteTable(struct IsoFile *isofile, struct TableData table); extern int BZip2V2WriteTable(struct IsoFile *isofile, struct TableData table);
extern int BZip2V2OpenForRead(struct IsoFile *isofile); extern int BZip2V2OpenForRead(struct IsoFile *isofile);
extern int BZip2V2Seek(struct IsoFile *isofile, off64_t sector); extern int BZip2V2Seek(struct IsoFile *isofile, off64_t sector);
extern int BZip2V2Read(struct IsoFile *isofile, int bytes, char *buffer); extern int BZip2V2Read(struct IsoFile *isofile, int bytes, char *buffer);
extern void BZip2V2Close(struct IsoFile *isofile); extern void BZip2V2Close(struct IsoFile *isofile);
extern int BZip2V2OpenForWrite(struct IsoFile *isofile); extern int BZip2V2OpenForWrite(struct IsoFile *isofile);
extern int BZip2V2Write(struct IsoFile *isofile, char *buffer); extern int BZip2V2Write(struct IsoFile *isofile, char *buffer);
#endif /* BZIP2V2_H */ #endif /* BZIP2V2_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,104 +1,46 @@
/* bzip2v3.h /* bzip2v3.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef BZIP2V3_H #ifndef BZIP2V3_H
#define BZIP2V3_H #define BZIP2V3_H
#include <sys/types.h> #include <sys/types.h>
#include "isofile.h" #include "isofile.h"
#include "isocompress.h" #include "isocompress.h"
// #define VERBOSE_FUNCTION_BZIP2V3 // #define VERBOSE_FUNCTION_BZIP2V3
// #define VERBOSE_WARNING_BZIP2V3 // #define VERBOSE_WARNING_BZIP2V3
extern int BZip2V3OpenTableForRead(struct IsoFile *isofile); extern int BZip2V3OpenTableForRead(struct IsoFile *isofile);
extern int BZip2V3SeekTable(struct IsoFile *isofile, off64_t sector); extern int BZip2V3SeekTable(struct IsoFile *isofile, off64_t sector);
extern int BZip2V3ReadTable(struct IsoFile *isofile, struct TableData *table); extern int BZip2V3ReadTable(struct IsoFile *isofile, struct TableData *table);
extern int BZip2V3OpenTableForWrite(struct IsoFile *isofile); extern int BZip2V3OpenTableForWrite(struct IsoFile *isofile);
extern int BZip2V3WriteTable(struct IsoFile *isofile, struct TableData table); extern int BZip2V3WriteTable(struct IsoFile *isofile, struct TableData table);
extern int BZip2V3OpenForRead(struct IsoFile *isofile); extern int BZip2V3OpenForRead(struct IsoFile *isofile);
extern int BZip2V3Seek(struct IsoFile *isofile, off64_t sector); extern int BZip2V3Seek(struct IsoFile *isofile, off64_t sector);
extern int BZip2V3Read(struct IsoFile *isofile, int bytes, char *buffer); extern int BZip2V3Read(struct IsoFile *isofile, int bytes, char *buffer);
extern void BZip2V3Close(struct IsoFile *isofile); extern void BZip2V3Close(struct IsoFile *isofile);
extern int BZip2V3OpenForWrite(struct IsoFile *isofile); extern int BZip2V3OpenForWrite(struct IsoFile *isofile);
extern int BZip2V3Write(struct IsoFile *isofile, char *buffer); extern int BZip2V3Write(struct IsoFile *isofile, char *buffer);
#endif /* BZIP2V3_H */ #endif /* BZIP2V3_H */

View File

@ -17,22 +17,18 @@
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> #include <stddef.h>
#include <sys/types.h> #include <sys/types.h>
#include "convert.h" #include "convert.h"
off64_t ConvertEndianOffset(off64_t number)
{
off64_t ConvertEndianOffset(off64_t number) {
#ifndef CONVERTLITTLEENDIAN #ifndef CONVERTLITTLEENDIAN
union { union
{
off64_t n; off64_t n;
char c[sizeof(off64_t)]; char c[sizeof(off64_t)];
} oldnumber, newnumber; } oldnumber, newnumber;
int i; int i;
oldnumber.n = number; oldnumber.n = number;
for (i = 0; i < sizeof(off64_t); i++) for (i = 0; i < sizeof(off64_t); i++)
newnumber.c[i] = oldnumber.c[sizeof(off64_t) - 1 - i]; newnumber.c[i] = oldnumber.c[sizeof(off64_t) - 1 - i];
@ -42,10 +38,11 @@ off64_t ConvertEndianOffset(off64_t number) {
#endif /* CONVERTLITTLEENDIAN */ #endif /* CONVERTLITTLEENDIAN */
} // END ConvertEndianOffset() } // END ConvertEndianOffset()
unsigned int ConvertEndianUInt(unsigned int number)
unsigned int ConvertEndianUInt(unsigned int number) { {
#ifndef CONVERTLITTLEENDIAN #ifndef CONVERTLITTLEENDIAN
union { union
{
unsigned int n; unsigned int n;
char c[sizeof(unsigned int)]; char c[sizeof(unsigned int)];
} oldnumber, newnumber; } oldnumber, newnumber;
@ -59,16 +56,15 @@ unsigned int ConvertEndianUInt(unsigned int number) {
return(number); return(number);
#endif /* CONVERTLITTLEENDIAN */ #endif /* CONVERTLITTLEENDIAN */
} // END ConvertEndianUInt() } // END ConvertEndianUInt()
unsigned short ConvertEndianUShort(unsigned short number)
{
unsigned short ConvertEndianUShort(unsigned short number) {
#ifndef CONVERTLITTLEENDIAN #ifndef CONVERTLITTLEENDIAN
union { union
{
unsigned short n; unsigned short n;
char c[sizeof(unsigned short)]; char c[sizeof(unsigned short)];
} oldnumber, newnumber; } oldnumber, newnumber;
int i; int i;
oldnumber.n = number; oldnumber.n = number;
for (i = 0; i < sizeof(unsigned short); i++) for (i = 0; i < sizeof(unsigned short); i++)
newnumber.c[i] = oldnumber.c[sizeof(unsigned short) - 1 - i]; newnumber.c[i] = oldnumber.c[sizeof(unsigned short) - 1 - i];
@ -78,12 +74,13 @@ unsigned short ConvertEndianUShort(unsigned short number) {
#endif /* CONVERTLITTLEENDIAN */ #endif /* CONVERTLITTLEENDIAN */
} // END ConvertEndianUShort() } // END ConvertEndianUShort()
// Note: deposits M/S/F data in buffer[0]/[1]/[2] respectively. // Note: deposits M/S/F data in buffer[0]/[1]/[2] respectively.
void LBAtoMSF(unsigned long lsn, char *buffer) { void LBAtoMSF(unsigned long lsn, char *buffer)
{
unsigned long templsn; unsigned long templsn;
if(lsn >= 0xFFFFFFFF - 150) { if (lsn >= 0xFFFFFFFF - 150)
{
*(buffer + 2) = 75 - 1; *(buffer + 2) = 75 - 1;
*(buffer + 1) = 60 - 1; *(buffer + 1) = 60 - 1;
*(buffer) = 100 - 1; *(buffer) = 100 - 1;
@ -99,13 +96,10 @@ void LBAtoMSF(unsigned long lsn, char *buffer) {
templsn /= 60; templsn /= 60;
*(buffer) = templsn; // Leftover quotient in minutes *(buffer) = templsn; // Leftover quotient in minutes
} // END LBAtoMSF() } // END LBAtoMSF()
unsigned long MSFtoLBA(char *buffer)
{
unsigned long MSFtoLBA(char *buffer) {
unsigned long templsn; unsigned long templsn;
if (buffer == NULL) return(0xFFFFFFFF); if (buffer == NULL) return(0xFFFFFFFF);
templsn = *(buffer); // Minutes templsn = *(buffer); // Minutes
templsn *= 60; templsn *= 60;
templsn += *(buffer + 1); // Seconds templsn += *(buffer + 1); // Seconds
@ -113,6 +107,5 @@ unsigned long MSFtoLBA(char *buffer) {
templsn += *(buffer + 2); // Frames templsn += *(buffer + 2); // Frames
if (templsn < 150) return(0xFFFFFFFF); if (templsn < 150) return(0xFFFFFFFF);
templsn -= 150; // Offset templsn -= 150; // Offset
return(templsn); return(templsn);
} // END MSFtoLBA() } // END MSFtoLBA()

View File

@ -17,12 +17,9 @@
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef CONVERT_H #ifndef CONVERT_H
#define CONVERT_H #define CONVERT_H
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
#include "PS2Etypes.h" #include "PS2Etypes.h"
#ifdef __linux__ #ifdef __linux__
@ -31,19 +28,15 @@
#define CONVERTLITTLEENDIAN #define CONVERTLITTLEENDIAN
#endif /* __BYTE_ORDER */ #endif /* __BYTE_ORDER */
#endif /* __linux__ */ #endif /* __linux__ */
#ifdef _WIN32 #ifdef _WIN32
#define CONVERTLITTLEENDIAN #define CONVERTLITTLEENDIAN
#endif /* _WIN32 */ #endif /* _WIN32 */
#define HEXTOBCD(i) (((i)/10*16) + ((i)%10)) #define HEXTOBCD(i) (((i)/10*16) + ((i)%10))
#define BCDTOHEX(i) (((i)/16*10) + ((i)%16)) #define BCDTOHEX(i) (((i)/16*10) + ((i)%16))
extern off64_t ConvertEndianOffset(off64_t number); extern off64_t ConvertEndianOffset(off64_t number);
extern unsigned int ConvertEndianUInt(unsigned int number); extern unsigned int ConvertEndianUInt(unsigned int number);
extern unsigned short ConvertEndianUShort(unsigned short number); extern unsigned short ConvertEndianUShort(unsigned short number);
extern void LBAtoMSF(unsigned long lsn, char *buffer); extern void LBAtoMSF(unsigned long lsn, char *buffer);
extern unsigned long MSFtoLBA(char *buffer); extern unsigned long MSFtoLBA(char *buffer);

View File

@ -1,118 +1,60 @@
/* ecma119.c /* ecma119.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> #include <stddef.h>
// #ifndef __LINUX__ // #ifndef __LINUX__
// #ifdef __linux__ // #ifdef __linux__
// #define __LINUX__ // #define __LINUX__
// #endif /* __linux__ */ // #endif /* __linux__ */
// #endif /* No __LINUX__ */ // #endif /* No __LINUX__ */
// #define CDVDdefs // #define CDVDdefs
// #include "PS2Edefs.h" // #include "PS2Edefs.h"
#include "ecma119.h" #include "ecma119.h"
const char ECMA119VolumeIDstdid[] = "CD001\0"; const char ECMA119VolumeIDstdid[] = "CD001\0";
int ValidateECMA119PrimaryVolume(struct ECMA119PrimaryVolume *volume)
{
int ValidateECMA119PrimaryVolume(struct ECMA119PrimaryVolume *volume) {
int i; int i;
if (volume == NULL) return(-1); if (volume == NULL) return(-1);
// Volume ID // Volume ID
if (volume->id.voltype != 1) return(-1); // Incorrect volume type if (volume->id.voltype != 1) return(-1); // Incorrect volume type
if (volume->id.version != 1) return(-1); // Not a Standard Version? if (volume->id.version != 1) return(-1); // Not a Standard Version?
i = 0; i = 0;
while ((ECMA119VolumeIDstdid[i] != 0) && while ((ECMA119VolumeIDstdid[i] != 0) &&
(ECMA119VolumeIDstdid[i] == volume->id.stdid[i])) i++; (ECMA119VolumeIDstdid[i] == volume->id.stdid[i])) i++;
if (ECMA119VolumeIDstdid[i] != 0) return(-1); // "CD001" did not match? if (ECMA119VolumeIDstdid[i] != 0) return(-1); // "CD001" did not match?
// Looks like numblocksle might give us maximum sector count... // Looks like numblocksle might give us maximum sector count...
// Looks like blocksizele can be compared to blocksize stored in isofile... // Looks like blocksizele can be compared to blocksize stored in isofile...
return(0); return(0);
} // END ValidateECMA119PrimaryVolume() } // END ValidateECMA119PrimaryVolume()
// Not sure the Partition Volume will be much help... // Not sure the Partition Volume will be much help...

View File

@ -1,468 +1,217 @@
/* ecma119.h /* ecma119.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef ECMA119_H #ifndef ECMA119_H
#define ECMA119_H #define ECMA119_H
// #ifndef __LINUX__ // #ifndef __LINUX__
// #ifdef __linux__ // #ifdef __linux__
// #define __LINUX__ // #define __LINUX__
// #endif /* __linux__ */ // #endif /* __linux__ */
// #endif /* No __LINUX__ */ // #endif /* No __LINUX__ */
// #define CDVDdefs // #define CDVDdefs
// #include "PS2Edefs.h" // #include "PS2Edefs.h"
// ECMA119 was sent to ISO to be fast-tracked into ISO 9660 // ECMA119 was sent to ISO to be fast-tracked into ISO 9660
// ECMA119 can be found at http://www.ecma.ch, somewhere. // ECMA119 can be found at http://www.ecma.ch, somewhere.
// Throughout these definitions, number pairs in both big-endian and // Throughout these definitions, number pairs in both big-endian and
// little-endian varieties are stored next to each other. To separate // little-endian varieties are stored next to each other. To separate
// the pairs a 'le' suffix has been attached to little-endian numbers, and // the pairs a 'le' suffix has been attached to little-endian numbers, and
// a 'be' suffix to big-endian ones. // a 'be' suffix to big-endian ones.
// All 'unused' entries should be set to (or tested for) 0x00. // All 'unused' entries should be set to (or tested for) 0x00.
#ifdef _WIN32 #ifdef _WIN32
#pragma pack(1) #pragma pack(1)
#endif /* _WIN32 */ #endif /* _WIN32 */
struct ECMA119ASCIITime
{
struct ECMA119ASCIITime {
char year[4]; char year[4];
char month[2]; char month[2];
char day[2]; char day[2];
char hour[2]; char hour[2];
char min[2]; char min[2];
char sec[2]; char sec[2];
char hundredthsec[2]; char hundredthsec[2];
char offsetgmt; // 15 min intervals, from -48 to +52 char offsetgmt; // 15 min intervals, from -48 to +52
#ifdef _WIN32 #ifdef _WIN32
}; };
#else #else
} __attribute__((packed)); } __attribute__((packed));
#endif /* _WIN32 */ #endif /* _WIN32 */
struct ECMA119DateTime
{
struct ECMA119DateTime {
unsigned char year; // 1900+year, that is. unsigned char year; // 1900+year, that is.
unsigned char month; unsigned char month;
unsigned char day; unsigned char day;
unsigned char hour; unsigned char hour;
unsigned char minute; unsigned char minute;
unsigned char sec; unsigned char sec;
signed char offsetgmt; // In 15 min intervals, from -48 to +52 signed char offsetgmt; // In 15 min intervals, from -48 to +52
#ifdef _WIN32 #ifdef _WIN32
}; };
#else #else
} __attribute__((packed)); } __attribute__((packed));
#endif /* _WIN32 */ #endif /* _WIN32 */
struct ECMA119DirectoryRecord
{
struct ECMA119DirectoryRecord {
unsigned char reclen; // Length of this record unsigned char reclen; // Length of this record
unsigned char attlen; // Extended Attribute Record Length unsigned char attlen; // Extended Attribute Record Length
unsigned long externlocle; // Location of Extent unsigned long externlocle; // Location of Extent
unsigned long externlocbe; unsigned long externlocbe;
struct ECMA119DateTime recorded; // Recording Date and Time struct ECMA119DateTime recorded; // Recording Date and Time
unsigned char flags; // File Flags unsigned char flags; // File Flags
unsigned char interleave; // Interleave Gap Size unsigned char interleave; // Interleave Gap Size
unsigned short seqnole; // Volume Sequence No. unsigned short seqnole; // Volume Sequence No.
unsigned short seqnobe; unsigned short seqnobe;
unsigned short idlen; unsigned short idlen;
char id[223]; char id[223];
// Note: sometimes a OS uses the end of this record for it's own use. // Note: sometimes a OS uses the end of this record for it's own use.
#ifdef _WIN32 #ifdef _WIN32
}; };
#else #else
} __attribute__((packed)); } __attribute__((packed));
#endif /* _WIN32 */ #endif /* _WIN32 */
struct ECMA119RootDirectoryRecord
{
struct ECMA119RootDirectoryRecord {
unsigned char reclen; // Length of this record unsigned char reclen; // Length of this record
unsigned char attlen; // Extended Attribute Record Length unsigned char attlen; // Extended Attribute Record Length
unsigned long externlocle; // Location of Extent unsigned long externlocle; // Location of Extent
unsigned long externlocbe; unsigned long externlocbe;
struct ECMA119DateTime recorded; // Recording Date and Time struct ECMA119DateTime recorded; // Recording Date and Time
unsigned char flags; // File Flags unsigned char flags; // File Flags
unsigned char interleave; // Interleave Gap Size unsigned char interleave; // Interleave Gap Size
unsigned short seqnole; // Volume Sequence No. unsigned short seqnole; // Volume Sequence No.
unsigned short seqnobe; unsigned short seqnobe;
unsigned short idlen; unsigned short idlen;
char id[1]; // Probably for the '.' (But I'm just guessing :) char id[1]; // Probably for the '.' (But I'm just guessing :)
#ifdef _WIN32 #ifdef _WIN32
}; };
#else #else
} __attribute__((packed)); } __attribute__((packed));
#endif /* _WIN32 */ #endif /* _WIN32 */
struct ECMA119VolumeID
{
struct ECMA119VolumeID {
unsigned char voltype; unsigned char voltype;
// 0 = Boot Record // 0 = Boot Record
// 1 = Primary Volume Descriptor (PrimaryVolume below) // 1 = Primary Volume Descriptor (PrimaryVolume below)
// 2 = Supplementary Volume Descriptor // 2 = Supplementary Volume Descriptor
// 3 = Partition Descriptor (PartitionVolume below) // 3 = Partition Descriptor (PartitionVolume below)
// 4 - 254 Reserved // 4 - 254 Reserved
// 255 = End-of-Descriptor-Set // 255 = End-of-Descriptor-Set
char stdid[5]; // Standard Identifier. Always "CD001" char stdid[5]; // Standard Identifier. Always "CD001"
unsigned char version; unsigned char version;
#ifdef _WIN32 #ifdef _WIN32
}; };
#else #else
} __attribute__((packed)); } __attribute__((packed));
#endif /* _WIN32 */ #endif /* _WIN32 */
struct ECMA119PrimaryVolume
{
struct ECMA119PrimaryVolume {
struct ECMA119VolumeID id; struct ECMA119VolumeID id;
// id.voltype should be 1 (for this type of volume) // id.voltype should be 1 (for this type of volume)
// id.version should be 1 (standard) // id.version should be 1 (standard)
char unused1; char unused1;
char systemid[32]; char systemid[32];
char volumeid[32]; char volumeid[32];
char unused2[8]; char unused2[8];
unsigned long numblocksle; // Total logical blocks. (on Media? or just unsigned long numblocksle; // Total logical blocks. (on Media? or just
unsigned long numblocksbe; // in volume?) unsigned long numblocksbe; // in volume?)
char unused3[32]; char unused3[32];
unsigned short volumesetsizele; // Volume Set size of the volume. (?) unsigned short volumesetsizele; // Volume Set size of the volume. (?)
unsigned short volumesetsizebe; unsigned short volumesetsizebe;
unsigned short ordinalle; // Count of which descriptor this is in the Volume unsigned short ordinalle; // Count of which descriptor this is in the Volume
unsigned short ordinalbe; // set. unsigned short ordinalbe; // set.
unsigned short blocksizele; // Size of a Logical Block unsigned short blocksizele; // Size of a Logical Block
unsigned short blocksizebe; unsigned short blocksizebe;
unsigned long pathtablesizele; // Path Table Size unsigned long pathtablesizele; // Path Table Size
unsigned long pathtablesizebe; unsigned long pathtablesizebe;
unsigned long typelpathtablelocation; // (le) Location of a Type L Path Table unsigned long typelpathtablelocation; // (le) Location of a Type L Path Table
unsigned long typelopttablelocation; // (le) Location of an Optional Type L unsigned long typelopttablelocation; // (le) Location of an Optional Type L
unsigned long typempathtablelocation; // (be) Location of a Type M Path Table unsigned long typempathtablelocation; // (be) Location of a Type M Path Table
unsigned long typemopttablelocation; // (be) Location of an Optional Type M unsigned long typemopttablelocation; // (be) Location of an Optional Type M
struct ECMA119RootDirectoryRecord root; struct ECMA119RootDirectoryRecord root;
char volumesetid[128]; // Volume Set ID char volumesetid[128]; // Volume Set ID
char publisher[128]; // Publisher char publisher[128]; // Publisher
char datapreparer[128]; // Data Preparer char datapreparer[128]; // Data Preparer
char application[128]; // Application ID char application[128]; // Application ID
char copyrightfile[37]; // Copyright File Identifier char copyrightfile[37]; // Copyright File Identifier
char abstractfile[37]; // Abstract File Identifier char abstractfile[37]; // Abstract File Identifier
char bibliograchicfile[37]; // Bibliographic File Identifier char bibliograchicfile[37]; // Bibliographic File Identifier
struct ECMA119ASCIITime volcreatedate; // Date Created struct ECMA119ASCIITime volcreatedate; // Date Created
struct ECMA119ASCIITime volmodifydate; // Last Date Modified struct ECMA119ASCIITime volmodifydate; // Last Date Modified
struct ECMA119ASCIITime volexpiredate; // Date data expires struct ECMA119ASCIITime volexpiredate; // Date data expires
struct ECMA119ASCIITime voleffectivedata; // Date data becomes accurate (effective) struct ECMA119ASCIITime voleffectivedata; // Date data becomes accurate (effective)
unsigned char filestructversion; // File Structure Version unsigned char filestructversion; // File Structure Version
// Should be 1 = Standard // Should be 1 = Standard
char unused4; char unused4;
char applicationuse[512]; // For use by an application char applicationuse[512]; // For use by an application
char unused5[653]; // Rounds this out to 2048 bytes... char unused5[653]; // Rounds this out to 2048 bytes...
#ifdef _WIN32 #ifdef _WIN32
}; };
#else #else
} __attribute__((packed)); } __attribute__((packed));
#endif /* _WIN32 */ #endif /* _WIN32 */
// struct ECMA119PartitionVolume { // struct ECMA119PartitionVolume {
// struct ECMA119VolumeID id; // struct ECMA119VolumeID id;
// #ifdef _WIN32 // #ifdef _WIN32
// }; // };
// #else // #else
// } __attribute__ ((packed)); // } __attribute__ ((packed));
// #endif /* _WIN32 */ // #endif /* _WIN32 */
#ifdef _WIN32 #ifdef _WIN32
#pragma pack() #pragma pack()
#endif /* _WIN32 */ #endif /* _WIN32 */
extern int ValidateECMA119PrimaryVolume(struct ECMA119PrimaryVolume *volume); extern int ValidateECMA119PrimaryVolume(struct ECMA119PrimaryVolume *volume);
// extern int ValidateECMA119PartitionVolume(struct ECMA119PartitionVolume volume); // extern int ValidateECMA119PartitionVolume(struct ECMA119PartitionVolume volume);
#endif /* ECMA119_H */ #endif /* ECMA119_H */

View File

@ -1,844 +1,410 @@
/* gzipv1.c /* gzipv1.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include "zlib/zlib.h" #include "zlib/zlib.h"
#include "convert.h" #include "convert.h"
#include "logfile.h" #include "logfile.h"
#include "isofile.h" #include "isofile.h"
#include "isocompress.h" // TableData #include "isocompress.h" // TableData
#include "actualfile.h" #include "actualfile.h"
#include "gzipv1.h" #include "gzipv1.h"
#ifdef _WIN32 #ifdef _WIN32
#pragma pack(1) #pragma pack(1)
#endif /* _WIN32 */ #endif /* _WIN32 */
struct GZipV1Table
{
struct GZipV1Table {
unsigned int offset; // Data file position unsigned int offset; // Data file position
unsigned short size; // of Compressed data unsigned short size; // of Compressed data
#ifdef _WIN32 #ifdef _WIN32
}; };
#else #else
} __attribute__((packed)); } __attribute__((packed));
#endif /* _WIN32 */ #endif /* _WIN32 */
#ifdef _WIN32 #ifdef _WIN32
#pragma pack() #pragma pack()
#endif /* _WIN32 */ #endif /* _WIN32 */
int GZipV1OpenTableForRead(struct IsoFile *isofile)
{
int GZipV1OpenTableForRead(struct IsoFile *isofile) {
int i; int i;
int j; int j;
char tableext[] = ".table\0"; char tableext[] = ".table\0";
#ifdef VERBOSE_FUNCTION_GZIPV1 #ifdef VERBOSE_FUNCTION_GZIPV1
PrintLog("CDVDiso GZipV1: OpenTableForRead()"); PrintLog("CDVDiso GZipV1: OpenTableForRead()");
#endif /* VERBOSE_FUNCTION_GZIPV1 */ #endif /* VERBOSE_FUNCTION_GZIPV1 */
i = 0; i = 0;
while ((i < 256) && (isofile->name[i] != 0))
while((i < 256) && (isofile->name[i] != 0)) { {
isofile->tablename[i] = isofile->name[i]; isofile->tablename[i] = isofile->name[i];
i++; i++;
} // ENDWHILE- Copying the data name to the table name } // ENDWHILE- Copying the data name to the table name
j = 0; j = 0;
while ((i < 256) && (tableext[j] != 0))
while((i < 256) && (tableext[j] != 0)) { {
isofile->tablename[i] = tableext[j]; isofile->tablename[i] = tableext[j];
i++; i++;
j++; j++;
} // ENDWHILE- Adding the ".table" extension. } // ENDWHILE- Adding the ".table" extension.
isofile->tablename[i] = 0; // And 0-terminate. isofile->tablename[i] = 0; // And 0-terminate.
isofile->tablehandle = ActualFileOpenForRead(isofile->tablename); isofile->tablehandle = ActualFileOpenForRead(isofile->tablename);
if (isofile->tablehandle == ACTUALHANDLENULL)
if(isofile->tablehandle == ACTUALHANDLENULL) { {
#ifdef VERBOSE_WARNING_GZIPV1 #ifdef VERBOSE_WARNING_GZIPV1
PrintLog("CDVDiso GZipV1: Couldn't open table!"); PrintLog("CDVDiso GZipV1: Couldn't open table!");
#endif /* VERBOSE_WARNING_GZIPV1 */ #endif /* VERBOSE_WARNING_GZIPV1 */
return(-2); return(-2);
} // ENDIF- Couldn't open table file? Fail. } // ENDIF- Couldn't open table file? Fail.
isofile->filesectorsize = ActualFileSize(isofile->tablehandle) isofile->filesectorsize = ActualFileSize(isofile->tablehandle)
/ sizeof(struct GZipV1Table); / sizeof(struct GZipV1Table);
return(0); return(0);
} // END GZipV1OpenTableForRead() } // END GZipV1OpenTableForRead()
int GZipV1SeekTable(struct IsoFile *isofile, off64_t sector)
{
int GZipV1SeekTable(struct IsoFile *isofile, off64_t sector) {
off64_t target; off64_t target;
int retval; int retval;
#ifdef VERBOSE_FUNCTION_GZIPV1 #ifdef VERBOSE_FUNCTION_GZIPV1
PrintLog("CDVDiso GZipV1: SeekTable(%lli)", sector); PrintLog("CDVDiso GZipV1: SeekTable(%lli)", sector);
#endif /* VERBOSE_FUNCTION_GZIPV1 */ #endif /* VERBOSE_FUNCTION_GZIPV1 */
target = sector * sizeof(struct GZipV1Table); target = sector * sizeof(struct GZipV1Table);
retval = ActualFileSeek(isofile->tablehandle, target); retval = ActualFileSeek(isofile->tablehandle, target);
if (retval < 0)
if(retval < 0) { {
#ifdef VERBOSE_WARNING_GZIPV1 #ifdef VERBOSE_WARNING_GZIPV1
PrintLog("CDVDiso GZipV1: Couldn't find sector!"); PrintLog("CDVDiso GZipV1: Couldn't find sector!");
#endif /* VERBOSE_WARNING_GZIPV1 */ #endif /* VERBOSE_WARNING_GZIPV1 */
return(-2); return(-2);
} // ENDIF- Trouble finding the place? Fail. } // ENDIF- Trouble finding the place? Fail.
isofile->filesectorpos = sector; isofile->filesectorpos = sector;
return(0); return(0);
} // END GZipV1SeekTable() } // END GZipV1SeekTable()
int GZipV1ReadTable(struct IsoFile *isofile, struct TableData *table)
{
int GZipV1ReadTable(struct IsoFile *isofile, struct TableData *table) {
int retval; int retval;
struct GZipV1Table temptable; struct GZipV1Table temptable;
#ifdef VERBOSE_FUNCTION_GZIPV1 #ifdef VERBOSE_FUNCTION_GZIPV1
PrintLog("CDVDiso GZipV1: ReadTable()"); PrintLog("CDVDiso GZipV1: ReadTable()");
#endif /* VERBOSE_FUNCTION_GZIPV1 */ #endif /* VERBOSE_FUNCTION_GZIPV1 */
retval = ActualFileRead(isofile->tablehandle, retval = ActualFileRead(isofile->tablehandle,
sizeof(struct GZipV1Table), sizeof(struct GZipV1Table),
(char *) & temptable); (char *) & temptable);
if (retval != sizeof(struct GZipV1Table))
if(retval != sizeof(struct GZipV1Table)) { {
#ifdef VERBOSE_WARNING_GZIPV1 #ifdef VERBOSE_WARNING_GZIPV1
PrintLog("CDVDiso GZipV1: Couldn't read table entry!"); PrintLog("CDVDiso GZipV1: Couldn't read table entry!");
#endif /* VERBOSE_WARNING_GZIPV1 */ #endif /* VERBOSE_WARNING_GZIPV1 */
return(-2); return(-2);
} // ENDIF- Trouble reading table entry? Fail. } // ENDIF- Trouble reading table entry? Fail.
table->offset = ConvertEndianUInt(temptable.offset); table->offset = ConvertEndianUInt(temptable.offset);
table->size = ConvertEndianUShort(temptable.size); table->size = ConvertEndianUShort(temptable.size);
isofile->filesectorpos++; isofile->filesectorpos++;
return(0); return(0);
} // END GZipV1ReadTable() } // END GZipV1ReadTable()
int GZipV1OpenTableForWrite(struct IsoFile *isofile)
{
int GZipV1OpenTableForWrite(struct IsoFile *isofile) {
int i; int i;
int j; int j;
char tableext[] = ".table\0"; char tableext[] = ".table\0";
#ifdef VERBOSE_FUNCTION_GZIPV1 #ifdef VERBOSE_FUNCTION_GZIPV1
PrintLog("CDVDiso GZipV1: OpenTableForWrite()"); PrintLog("CDVDiso GZipV1: OpenTableForWrite()");
#endif /* VERBOSE_FUNCTION_GZIPV1 */ #endif /* VERBOSE_FUNCTION_GZIPV1 */
i = 0; i = 0;
while ((i < 256) && (isofile->name[i] != 0))
while((i < 256) && (isofile->name[i] != 0)) { {
isofile->tablename[i] = isofile->name[i]; isofile->tablename[i] = isofile->name[i];
i++; i++;
} // ENDWHILE- Copying the data name to the table name } // ENDWHILE- Copying the data name to the table name
j = 0; j = 0;
while ((i < 256) && (tableext[j] != 0))
while((i < 256) && (tableext[j] != 0)) { {
isofile->tablename[i] = tableext[j]; isofile->tablename[i] = tableext[j];
i++; i++;
j++; j++;
} // ENDWHILE- Adding the ".table" extension. } // ENDWHILE- Adding the ".table" extension.
isofile->tablename[i] = 0; // And 0-terminate. isofile->tablename[i] = 0; // And 0-terminate.
isofile->tablehandle = ActualFileOpenForWrite(isofile->tablename); isofile->tablehandle = ActualFileOpenForWrite(isofile->tablename);
if (isofile->tablehandle == ACTUALHANDLENULL)
if(isofile->tablehandle == ACTUALHANDLENULL) { {
#ifdef VERBOSE_WARNING_GZIPV1 #ifdef VERBOSE_WARNING_GZIPV1
PrintLog("CDVDiso GZipV1: Couldn't open table!"); PrintLog("CDVDiso GZipV1: Couldn't open table!");
#endif /* VERBOSE_WARNING_GZIPV1 */ #endif /* VERBOSE_WARNING_GZIPV1 */
return(-2); return(-2);
} // ENDIF- Couldn't open table file? Fail. } // ENDIF- Couldn't open table file? Fail.
isofile->filesectorsize = 0; isofile->filesectorsize = 0;
return(0); return(0);
} // END GZipV1OpenTableForWrite() } // END GZipV1OpenTableForWrite()
int GZipV1WriteTable(struct IsoFile *isofile, struct TableData table)
{
int GZipV1WriteTable(struct IsoFile *isofile, struct TableData table) {
int retval; int retval;
struct GZipV1Table temptable; struct GZipV1Table temptable;
unsigned int tempint; unsigned int tempint;
#ifdef VERBOSE_FUNCTION_GZIPV1 #ifdef VERBOSE_FUNCTION_GZIPV1
PrintLog("CDVDiso GZipV1: WriteTable(%lli, %i)", table.offset, table.size); PrintLog("CDVDiso GZipV1: WriteTable(%lli, %i)", table.offset, table.size);
#endif /* VERBOSE_FUNCTION_GZIPV1 */ #endif /* VERBOSE_FUNCTION_GZIPV1 */
tempint = table.offset; tempint = table.offset;
temptable.offset = ConvertEndianUInt(tempint); temptable.offset = ConvertEndianUInt(tempint);
temptable.size = ConvertEndianUShort(table.size); temptable.size = ConvertEndianUShort(table.size);
retval = ActualFileWrite(isofile->tablehandle, retval = ActualFileWrite(isofile->tablehandle,
sizeof(struct GZipV1Table), sizeof(struct GZipV1Table),
(char *) & temptable); (char *) & temptable);
if (retval != sizeof(struct GZipV1Table))
if(retval != sizeof(struct GZipV1Table)) { {
#ifdef VERBOSE_WARNING_GZIPV1 #ifdef VERBOSE_WARNING_GZIPV1
PrintLog("CDVDiso GZipV1: Couldn't write table entry!"); PrintLog("CDVDiso GZipV1: Couldn't write table entry!");
#endif /* VERBOSE_WARNING_GZIPV1 */ #endif /* VERBOSE_WARNING_GZIPV1 */
return(-2); return(-2);
} // ENDIF- Trouble reading table entry? Fail. } // ENDIF- Trouble reading table entry? Fail.
return(0); return(0);
} // END GZipV1WriteTable() } // END GZipV1WriteTable()
int GZipV1OpenForRead(struct IsoFile *isofile)
{
int GZipV1OpenForRead(struct IsoFile *isofile) {
int retval; int retval;
char tempblock[2448]; char tempblock[2448];
#ifdef VERBOSE_FUNCTION_GZIPV1 #ifdef VERBOSE_FUNCTION_GZIPV1
PrintLog("CDVDiso GZipV1: OpenForRead()"); PrintLog("CDVDiso GZipV1: OpenForRead()");
#endif /* VERBOSE_FUNCTION_GZIPV1 */ #endif /* VERBOSE_FUNCTION_GZIPV1 */
isofile->handle = ActualFileOpenForRead(isofile->name); isofile->handle = ActualFileOpenForRead(isofile->name);
if (isofile->handle == ACTUALHANDLENULL)
if(isofile->handle == ACTUALHANDLENULL) { {
return(-1); return(-1);
} // ENDIF- Couldn't open data file? Fail. } // ENDIF- Couldn't open data file? Fail.
isofile->filebytesize = ActualFileSize(isofile->handle); isofile->filebytesize = ActualFileSize(isofile->handle);
isofile->filebytepos = 0; isofile->filebytepos = 0;
isofile->filesectorpos = 0; isofile->filesectorpos = 0;
isofile->imageheader = 0; isofile->imageheader = 0;
isofile->blocksize = 2352; isofile->blocksize = 2352;
isofile->blockoffset = 0; // Don't panic. "imagetype.c" will test later. isofile->blockoffset = 0; // Don't panic. "imagetype.c" will test later.
isofile->numsectors = 1; // Sectors per block isofile->numsectors = 1; // Sectors per block
retval = GZipV1Read(isofile, 2448, tempblock); retval = GZipV1Read(isofile, 2448, tempblock);
if (retval != 0)
if(retval != 0) { {
#ifdef VERBOSE_WARNING_GZIPV1 #ifdef VERBOSE_WARNING_GZIPV1
PrintLog("CDVDiso GZipV1: Couldn't decode the first block. Not compressed?"); PrintLog("CDVDiso GZipV1: Couldn't decode the first block. Not compressed?");
#endif /* VERBOSE_WARNING_GZIPV1 */ #endif /* VERBOSE_WARNING_GZIPV1 */
ActualFileClose(isofile->handle); ActualFileClose(isofile->handle);
isofile->handle = ACTUALHANDLENULL; isofile->handle = ACTUALHANDLENULL;
return(-1); return(-1);
} // ENDIF Could not read the first sector? Fail. } // ENDIF Could not read the first sector? Fail.
ActualFileSeek(isofile->handle, 0); // Restart at top of file ActualFileSeek(isofile->handle, 0); // Restart at top of file
isofile->filebytepos = 0; isofile->filebytepos = 0;
isofile->filesectorpos = 0; isofile->filesectorpos = 0;
return(0); return(0);
} // END GZipV1OpenForRead() } // END GZipV1OpenForRead()
int GZipV1Seek(struct IsoFile *isofile, off64_t position)
{
int GZipV1Seek(struct IsoFile *isofile, off64_t position) {
int retval; int retval;
#ifdef VERBOSE_FUNCTION_GZIPV1 #ifdef VERBOSE_FUNCTION_GZIPV1
PrintLog("CDVDiso GZipV1: Seek(%lli)", position); PrintLog("CDVDiso GZipV1: Seek(%lli)", position);
#endif /* VERBOSE_FUNCTION_GZIPV1 */ #endif /* VERBOSE_FUNCTION_GZIPV1 */
retval = ActualFileSeek(isofile->handle, position); retval = ActualFileSeek(isofile->handle, position);
if (retval < 0)
if(retval < 0) { {
#ifdef VERBOSE_WARNING_GZIPV1 #ifdef VERBOSE_WARNING_GZIPV1
PrintLog("CDVDiso GZipV1: Couldn't find the start of the compressed block!"); PrintLog("CDVDiso GZipV1: Couldn't find the start of the compressed block!");
#endif /* VERBOSE_WARNING_GZIPV1 */ #endif /* VERBOSE_WARNING_GZIPV1 */
return(-1); return(-1);
} // ENDIF- Couldn't find the data entry? Fail. } // ENDIF- Couldn't find the data entry? Fail.
isofile->filebytepos = position; isofile->filebytepos = position;
return(0); return(0);
return(-1); // Fail. (Due to lack of ambition?) return(-1); // Fail. (Due to lack of ambition?)
} // END GZipV1Seek() } // END GZipV1Seek()
int GZipV1Read(struct IsoFile *isofile, int bytes, char *buffer)
{
int GZipV1Read(struct IsoFile *isofile, int bytes, char *buffer) {
int retval; int retval;
unsigned long blocklen; unsigned long blocklen;
z_stream strm; z_stream strm;
unsigned long tempin; unsigned long tempin;
char tempblock[2800]; char tempblock[2800];
unsigned long tempout; unsigned long tempout;
#ifdef VERBOSE_FUNCTION_GZIPV1 #ifdef VERBOSE_FUNCTION_GZIPV1
PrintLog("CDVDiso GZipV1: Read(%i)", bytes); PrintLog("CDVDiso GZipV1: Read(%i)", bytes);
#endif /* VERBOSE_FUNCTION_GZIPV1 */ #endif /* VERBOSE_FUNCTION_GZIPV1 */
if (bytes > 0)
{
if(bytes > 0) {
retval = ActualFileRead(isofile->handle, bytes, tempblock); retval = ActualFileRead(isofile->handle, bytes, tempblock);
if (retval > 0) isofile->filebytepos += retval; if (retval > 0) isofile->filebytepos += retval;
if (retval != bytes)
if(retval != bytes) { {
#ifdef VERBOSE_WARNING_GZIPV1 #ifdef VERBOSE_WARNING_GZIPV1
PrintLog("CDVDiso GZipV1: Cannot read bytes! Returned: (%i)", retval); PrintLog("CDVDiso GZipV1: Cannot read bytes! Returned: (%i)", retval);
#endif /* VERBOSE_WARNING_GZIPV1 */ #endif /* VERBOSE_WARNING_GZIPV1 */
return(-1); return(-1);
} // ENDIF- Trouble reading compressed sector? Abort. } // ENDIF- Trouble reading compressed sector? Abort.
blocklen = isofile->blocksize; blocklen = isofile->blocksize;
retval = uncompress(buffer, &blocklen, tempblock, bytes); retval = uncompress(buffer, &blocklen, tempblock, bytes);
if (retval != Z_OK)
if(retval != Z_OK) { {
#ifdef VERBOSE_WARNING_GZIPV1 #ifdef VERBOSE_WARNING_GZIPV1
PrintLog("CDVDiso GZipV1: Cannot decode block! Returned: (%i)", retval); PrintLog("CDVDiso GZipV1: Cannot decode block! Returned: (%i)", retval);
#endif /* VERBOSE_WARNING_GZIPV1 */ #endif /* VERBOSE_WARNING_GZIPV1 */
return(-1); return(-1);
} // ENDIF- Trouble decoding the sector? Abort. } // ENDIF- Trouble decoding the sector? Abort.
return(0); return(0);
} // ENDIF- Do we know how many compressed bytes to get for this record? } // ENDIF- Do we know how many compressed bytes to get for this record?
// Hmm. Don't know the compressed size? Well, we'll just have to find it. // Hmm. Don't know the compressed size? Well, we'll just have to find it.
tempin = 0; tempin = 0;
tempout = 0; tempout = 0;
retval = Z_OK; retval = Z_OK;
while ((tempin < 2800) && (tempout < 2352))
while((tempin < 2800) && (tempout < 2352)) { {
strm.zalloc = (alloc_func)0; strm.zalloc = (alloc_func)0;
strm.zfree = (free_func)0; strm.zfree = (free_func)0;
strm.next_in = tempblock; strm.next_in = tempblock;
strm.next_out = buffer; strm.next_out = buffer;
strm.avail_in = tempin; strm.avail_in = tempin;
strm.avail_out = 2800; strm.avail_out = 2800;
retval = inflateInit(&strm); retval = inflateInit(&strm);
if (retval != Z_OK) return(-1); if (retval != Z_OK) return(-1);
while ((tempin < 2800) && (retval == Z_OK))
{
while((tempin < 2800) && (retval == Z_OK)) {
retval = ActualFileRead(isofile->handle, 1, &tempblock[tempin]); retval = ActualFileRead(isofile->handle, 1, &tempblock[tempin]);
if (retval != 1)
if(retval != 1) { {
#ifdef VERBOSE_WARNING_GZIPV1 #ifdef VERBOSE_WARNING_GZIPV1
PrintLog("CDVDiso GZipV1: Cannot read a byte! Returned: (%i)", retval); PrintLog("CDVDiso GZipV1: Cannot read a byte! Returned: (%i)", retval);
#endif /* VERBOSE_WARNING_GZIPV1 */ #endif /* VERBOSE_WARNING_GZIPV1 */
return(-1); return(-1);
} // ENDIF- Trouble reading compressed sector? Abort. } // ENDIF- Trouble reading compressed sector? Abort.
tempin++; tempin++;
strm.avail_in++; strm.avail_in++;
strm.next_in = &tempblock[tempin - strm.avail_in]; strm.next_in = &tempblock[tempin - strm.avail_in];
retval = inflate(&strm, Z_NO_FLUSH); retval = inflate(&strm, Z_NO_FLUSH);
} // ENDWHILE- trying to uncompress an increasingly filled buffer } // ENDWHILE- trying to uncompress an increasingly filled buffer
tempout = strm.total_out; tempout = strm.total_out;
inflateEnd(&strm); inflateEnd(&strm);
#ifdef VERBOSE_FUNCTION_GZIPV1 #ifdef VERBOSE_FUNCTION_GZIPV1
PrintLog("CDVDiso GZipV1: tempin=%lu tempout=%lu retval=%i", PrintLog("CDVDiso GZipV1: tempin=%lu tempout=%lu retval=%i",
tempin, tempout, retval); tempin, tempout, retval);
#endif /* VERBOSE_FUNCTION_GZIPV1 */ #endif /* VERBOSE_FUNCTION_GZIPV1 */
} // ENDWHILE- trying to uncompress a whole buffer } // ENDWHILE- trying to uncompress a whole buffer
if (retval != Z_STREAM_END)
if(retval != Z_STREAM_END) { {
#ifdef VERBOSE_WARNING_GZIPV1 #ifdef VERBOSE_WARNING_GZIPV1
PrintLog("CDVDiso GZipV1: Failed to decode block! Returned: (%i)", retval); PrintLog("CDVDiso GZipV1: Failed to decode block! Returned: (%i)", retval);
#endif /* VERBOSE_WARNING_GZIPV1 */ #endif /* VERBOSE_WARNING_GZIPV1 */
return(-1); return(-1);
} // ENDIF- Trouble reading compressed sector? Abort. } // ENDIF- Trouble reading compressed sector? Abort.
if (tempin == 2800)
{
if(tempin == 2800) {
#ifdef VERBOSE_WARNING_GZIPV1 #ifdef VERBOSE_WARNING_GZIPV1
PrintLog("CDVDiso GZipV1: Overfilled input buffer for only %llu bytes!", tempout); PrintLog("CDVDiso GZipV1: Overfilled input buffer for only %llu bytes!", tempout);
#endif /* VERBOSE_WARNING_GZIPV1 */ #endif /* VERBOSE_WARNING_GZIPV1 */
return(-1); return(-1);
} // ENDIF- Trouble reading compressed sector? Abort. } // ENDIF- Trouble reading compressed sector? Abort.
isofile->filebytepos += tempin; isofile->filebytepos += tempin;
return(tempin); // Send out # of compressed bytes (to record in table) return(tempin); // Send out # of compressed bytes (to record in table)
} // END GZipV1Read() } // END GZipV1Read()
int GZipV1OpenForWrite(struct IsoFile *isofile)
{
int GZipV1OpenForWrite(struct IsoFile *isofile) {
if (isofile == NULL) return(-1); if (isofile == NULL) return(-1);
#ifdef VERBOSE_FUNCTION_GZIPV1 #ifdef VERBOSE_FUNCTION_GZIPV1
PrintLog("CDVDiso GZipV1: OpenForWrite()"); PrintLog("CDVDiso GZipV1: OpenForWrite()");
#endif /* VERBOSE_FUNCTION_GZIPV1 */ #endif /* VERBOSE_FUNCTION_GZIPV1 */
isofile->handle = ActualFileOpenForWrite(isofile->name); isofile->handle = ActualFileOpenForWrite(isofile->name);
if (isofile->handle == ACTUALHANDLENULL)
if(isofile->handle == ACTUALHANDLENULL) { {
return(-1); return(-1);
} // ENDIF- Couldn't open data file? Fail. } // ENDIF- Couldn't open data file? Fail.
isofile->filebytesize = 0; isofile->filebytesize = 0;
isofile->filebytepos = 0; isofile->filebytepos = 0;
return(0); return(0);
} // END GZipV1OpenForWrite() } // END GZipV1OpenForWrite()
int GZipV1Write(struct IsoFile *isofile, char *buffer)
{
int GZipV1Write(struct IsoFile *isofile, char *buffer) {
int retval; int retval;
unsigned long blocklen; unsigned long blocklen;
char tempblock[2800]; char tempblock[2800];
#ifdef VERBOSE_FUNCTION_GZIPV1 #ifdef VERBOSE_FUNCTION_GZIPV1
PrintLog("CDVDiso GZipV1: Write()"); PrintLog("CDVDiso GZipV1: Write()");
#endif /* VERBOSE_FUNCTION_GZIPV1 */ #endif /* VERBOSE_FUNCTION_GZIPV1 */
blocklen = 2800; blocklen = 2800;
retval = compress2(tempblock, &blocklen, retval = compress2(tempblock, &blocklen,
buffer, 2352, buffer, 2352,
Z_BEST_COMPRESSION); Z_BEST_COMPRESSION);
if (retval != Z_OK)
if(retval != Z_OK) { {
#ifdef VERBOSE_FUNCTION_GZIPV1 #ifdef VERBOSE_FUNCTION_GZIPV1
PrintLog("CDVDiso GZipV1: Cannot encode block! Returned: (%i)", retval); PrintLog("CDVDiso GZipV1: Cannot encode block! Returned: (%i)", retval);
#endif /* VERBOSE_FUNCTION_GZIPV1 */ #endif /* VERBOSE_FUNCTION_GZIPV1 */
return(-1); return(-1);
} // ENDIF- Trouble compressing a block? Abort. } // ENDIF- Trouble compressing a block? Abort.
retval = ActualFileWrite(isofile->handle, blocklen, tempblock); retval = ActualFileWrite(isofile->handle, blocklen, tempblock);
if (retval > 0) isofile->filebytepos += retval; if (retval > 0) isofile->filebytepos += retval;
if (retval < blocklen)
if(retval < blocklen) { {
#ifdef VERBOSE_FUNCTION_GZIPV1 #ifdef VERBOSE_FUNCTION_GZIPV1
PrintLog("CDVDiso GZipV1: Cannot write bytes! Returned: (%i out of %llu)", PrintLog("CDVDiso GZipV1: Cannot write bytes! Returned: (%i out of %llu)",
retval, blocklen); retval, blocklen);
#endif /* VERBOSE_FUNCTION_GZIPV1 */ #endif /* VERBOSE_FUNCTION_GZIPV1 */
return(-1); return(-1);
} // ENDIF- Trouble writing out the compressed block? Abort. } // ENDIF- Trouble writing out the compressed block? Abort.
isofile->filesectorpos++; isofile->filesectorpos++;
return(blocklen); return(blocklen);
} // END GZipV1Write() } // END GZipV1Write()
void GZipV1Close(struct IsoFile *isofile)
{
void GZipV1Close(struct IsoFile *isofile) {
#ifdef VERBOSE_FUNCTION_GZIPV1 #ifdef VERBOSE_FUNCTION_GZIPV1
PrintLog("CDVDiso GZipV1: Close()"); PrintLog("CDVDiso GZipV1: Close()");
#endif /* VERBOSE_FUNCTION_GZIPV1 */ #endif /* VERBOSE_FUNCTION_GZIPV1 */
// Flush Write data... if any was held in the compression block area. // Flush Write data... if any was held in the compression block area.
// In this case, though... nothing's held there. // In this case, though... nothing's held there.
if (isofile->tablehandle != ACTUALHANDLENULL)
{
if(isofile->tablehandle != ACTUALHANDLENULL) {
ActualFileClose(isofile->tablehandle); ActualFileClose(isofile->tablehandle);
isofile->tablehandle = ACTUALHANDLENULL; isofile->tablehandle = ACTUALHANDLENULL;
} // ENDIF- Is there a table file open? Close it. } // ENDIF- Is there a table file open? Close it.
if (isofile->handle != ACTUALHANDLENULL)
{
if(isofile->handle != ACTUALHANDLENULL) {
ActualFileClose(isofile->handle); ActualFileClose(isofile->handle);
isofile->handle = ACTUALHANDLENULL; isofile->handle = ACTUALHANDLENULL;
} // ENDIF- Is there a data file open? Close it. } // ENDIF- Is there a data file open? Close it.
return; return;
} // END GZipV1Close() } // END GZipV1Close()

View File

@ -1,104 +1,46 @@
/* gzipv1.h /* gzipv1.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef GZIPV1_H #ifndef GZIPV1_H
#define GZIPV1_H #define GZIPV1_H
#include <sys/types.h> #include <sys/types.h>
#include "isofile.h" #include "isofile.h"
#include "isocompress.h" #include "isocompress.h"
// #define VERBOSE_FUNCTION_GZIPV1 // #define VERBOSE_FUNCTION_GZIPV1
// #define VERBOSE_WARNING_GZIPV1 // #define VERBOSE_WARNING_GZIPV1
extern int GZipV1OpenTableForRead(struct IsoFile *isofile); extern int GZipV1OpenTableForRead(struct IsoFile *isofile);
extern int GZipV1SeekTable(struct IsoFile *isofile, off64_t sector); extern int GZipV1SeekTable(struct IsoFile *isofile, off64_t sector);
extern int GZipV1ReadTable(struct IsoFile *isofile, struct TableData *table); extern int GZipV1ReadTable(struct IsoFile *isofile, struct TableData *table);
extern int GZipV1OpenTableForWrite(struct IsoFile *isofile); extern int GZipV1OpenTableForWrite(struct IsoFile *isofile);
extern int GZipV1WriteTable(struct IsoFile *isofile, struct TableData table); extern int GZipV1WriteTable(struct IsoFile *isofile, struct TableData table);
extern int GZipV1OpenForRead(struct IsoFile *isofile); extern int GZipV1OpenForRead(struct IsoFile *isofile);
extern int GZipV1Seek(struct IsoFile *isofile, off64_t sector); extern int GZipV1Seek(struct IsoFile *isofile, off64_t sector);
extern int GZipV1Read(struct IsoFile *isofile, int bytes, char *buffer); extern int GZipV1Read(struct IsoFile *isofile, int bytes, char *buffer);
extern void GZipV1Close(struct IsoFile *isofile); extern void GZipV1Close(struct IsoFile *isofile);
extern int GZipV1OpenForWrite(struct IsoFile *isofile); extern int GZipV1OpenForWrite(struct IsoFile *isofile);
extern int GZipV1Write(struct IsoFile *isofile, char *buffer); extern int GZipV1Write(struct IsoFile *isofile, char *buffer);
#endif /* GZIPV1_H */ #endif /* GZIPV1_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,104 +1,46 @@
/* gzipv2.h /* gzipv2.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef GZIPV2_H #ifndef GZIPV2_H
#define GZIPV2_H #define GZIPV2_H
#include <sys/types.h> #include <sys/types.h>
#include "isofile.h" #include "isofile.h"
#include "isocompress.h" #include "isocompress.h"
// #define VERBOSE_FUNCTION_GZIPV2 // #define VERBOSE_FUNCTION_GZIPV2
// #define VERBOSE_WARNING_GZIPV2 // #define VERBOSE_WARNING_GZIPV2
extern int GZipV2OpenTableForRead(struct IsoFile *isofile); extern int GZipV2OpenTableForRead(struct IsoFile *isofile);
extern int GZipV2SeekTable(struct IsoFile *isofile, off64_t sector); extern int GZipV2SeekTable(struct IsoFile *isofile, off64_t sector);
extern int GZipV2ReadTable(struct IsoFile *isofile, struct TableData *table); extern int GZipV2ReadTable(struct IsoFile *isofile, struct TableData *table);
extern int GZipV2OpenTableForWrite(struct IsoFile *isofile); extern int GZipV2OpenTableForWrite(struct IsoFile *isofile);
extern int GZipV2WriteTable(struct IsoFile *isofile, struct TableData table); extern int GZipV2WriteTable(struct IsoFile *isofile, struct TableData table);
extern int GZipV2OpenForRead(struct IsoFile *isofile); extern int GZipV2OpenForRead(struct IsoFile *isofile);
extern int GZipV2Seek(struct IsoFile *isofile, off64_t sector); extern int GZipV2Seek(struct IsoFile *isofile, off64_t sector);
extern int GZipV2Read(struct IsoFile *isofile, int bytes, char *buffer); extern int GZipV2Read(struct IsoFile *isofile, int bytes, char *buffer);
extern void GZipV2Close(struct IsoFile *isofile); extern void GZipV2Close(struct IsoFile *isofile);
extern int GZipV2OpenForWrite(struct IsoFile *isofile); extern int GZipV2OpenForWrite(struct IsoFile *isofile);
extern int GZipV2Write(struct IsoFile *isofile, char *buffer); extern int GZipV2Write(struct IsoFile *isofile, char *buffer);
#endif /* GZIPV2_H */ #endif /* GZIPV2_H */

View File

@ -1,306 +1,154 @@
/* imagetype.c /* imagetype.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
// #ifndef __LINUX__ // #ifndef __LINUX__
// #ifdef __linux__ // #ifdef __linux__
// #define __LINUX__ // #define __LINUX__
// #endif /* __linux__ */ // #endif /* __linux__ */
// #endif /* No __LINUX__ */ // #endif /* No __LINUX__ */
// #define CDVDdefs // #define CDVDdefs
// #include "PS2Edefs.h" // #include "PS2Edefs.h"
#include "isofile.h" #include "isofile.h"
#include "actualfile.h" #include "actualfile.h"
#include "imagetype.h" #include "imagetype.h"
// Based (mostly) off of florin's CDVDbin detection code, twice removed // Based (mostly) off of florin's CDVDbin detection code, twice removed
// with some additions from the <linux/cdrom.h> header. // with some additions from the <linux/cdrom.h> header.
struct ImageTypes imagedata[] =
struct ImageTypes imagedata[] = { {
{ "ISO 2048", 2048, 0, 0, 0 }, { "ISO 2048", 2048, 0, 0, 0 },
{ "YellowBook 2064", 2064, 0, 16, 1 }, { "YellowBook 2064", 2064, 0, 16, 1 },
{ "RAW 2064", 2064, 0, 0, 2 }, { "RAW 2064", 2064, 0, 0, 2 },
{ "GreenBook 2072", 2072, 0, 24, 3 }, { "GreenBook 2072", 2072, 0, 24, 3 },
{ "RAW 2072", 2072, 0, 0, 4 }, { "RAW 2072", 2072, 0, 0, 4 },
{ "RAW 2324", 2324, 0, 0, 5 }, { "RAW 2324", 2324, 0, 0, 5 },
{ "RAW 2328", 2328, 0, 0, 6 }, { "RAW 2328", 2328, 0, 0, 6 },
{ "RAW 2336", 2336, 0, 0, 7 }, { "RAW 2336", 2336, 0, 0, 7 },
{ "GreenBook 2352", 2352, 0, 24, 8 }, { "GreenBook 2352", 2352, 0, 24, 8 },
{ "YellowBook 2352", 2352, 0, 16, 9 }, { "YellowBook 2352", 2352, 0, 16, 9 },
{ "RedBook 2352", 2352, 0, 0, 10 }, { "RedBook 2352", 2352, 0, 0, 10 },
{ "RAWQ 2448", 2448, 0, 0, 11 }, { "RAWQ 2448", 2448, 0, 0, 11 },
{ "NERO ISO 2048", 2048, 150*2048, 0, 0 }, { "NERO ISO 2048", 2048, 150*2048, 0, 0 },
{ "NERO GreenBook 2352", 2352, 150*2352, 24, 8 }, { "NERO GreenBook 2352", 2352, 150*2352, 24, 8 },
{ "NERO YellowBook 2352", 2352, 150*2352, 16, 9 }, { "NERO YellowBook 2352", 2352, 150*2352, 16, 9 },
{ "NERO RedBook 2352", 2352, 150*2352, 0, 10 }, { "NERO RedBook 2352", 2352, 150*2352, 0, 10 },
{ "NERO RAWQ 2448", 2448, 150*2448, 0, 11 }, { "NERO RAWQ 2448", 2448, 150*2448, 0, 11 },
{ "Alt ISO 2048", 2048, 8, 0, 0 }, { "Alt ISO 2048", 2048, 8, 0, 0 },
{ "Alt RAW 2336", 2336, 8, 0, 7 }, { "Alt RAW 2336", 2336, 8, 0, 7 },
{ "Alt GreenBook 2352", 2352, 8, 24, 8 }, { "Alt GreenBook 2352", 2352, 8, 24, 8 },
{ "Alt YellowBook 2352", 2352, 8, 16, 9 }, { "Alt YellowBook 2352", 2352, 8, 16, 9 },
{ "Alt RedBook 2352", 2352, 8, 0, 10 }, { "Alt RedBook 2352", 2352, 8, 0, 10 },
{ "Alt RAWQ 2448", 2448, 8, 0, 11 }, { "Alt RAWQ 2448", 2448, 8, 0, 11 },
{ NULL, 0, 0, 0, 0 } { NULL, 0, 0, 0, 0 }
}; };
#define REDBOOK2352 10 #define REDBOOK2352 10
void GetImageType(struct IsoFile *isofile, int imagetype)
{
void GetImageType(struct IsoFile *isofile, int imagetype) {
int temptype; int temptype;
int i; int i;
temptype = imagetype; temptype = imagetype;
if ((temptype < 0) || (temptype > 22)) temptype = REDBOOK2352; if ((temptype < 0) || (temptype > 22)) temptype = REDBOOK2352;
i = 0; i = 0;
while ((i < 40) && (*(imagedata[temptype].name + i) != 0))
while((i < 40) && (*(imagedata[temptype].name + i) != 0)) { {
isofile->imagename[i] = *(imagedata[temptype].name + i); isofile->imagename[i] = *(imagedata[temptype].name + i);
i++; i++;
} // ENDWHILE- filling in the image name } // ENDWHILE- filling in the image name
isofile->imagename[i] = 0; // And 0-terminate. isofile->imagename[i] = 0; // And 0-terminate.
isofile->blocksize = imagedata[temptype].blocksize; isofile->blocksize = imagedata[temptype].blocksize;
isofile->imageheader = imagedata[temptype].fileoffset; isofile->imageheader = imagedata[temptype].fileoffset;
isofile->blockoffset = imagedata[temptype].dataoffset; isofile->blockoffset = imagedata[temptype].dataoffset;
} // END GetImageType() } // END GetImageType()
int GetImageTypeConvertTo(int imagetype)
{
int GetImageTypeConvertTo(int imagetype) {
return(imagedata[imagetype].conversiontype); return(imagedata[imagetype].conversiontype);
} // END GetImageTypeConvertTo() } // END GetImageTypeConvertTo()
int DetectImageType(struct IsoFile *isofile)
{
int DetectImageType(struct IsoFile *isofile) {
char comparestr[] = "CD001"; char comparestr[] = "CD001";
int newtype; int newtype;
off64_t targetpos; off64_t targetpos;
char teststr[2448]; char teststr[2448];
int dataoffset; int dataoffset;
int i; int i;
int retval; int retval;
newtype = 0; newtype = 0;
if (isofile->compress > 0)
if(isofile->compress > 0) { {
IsoFileSeek(isofile, 16); IsoFileSeek(isofile, 16);
IsoFileRead(isofile, teststr); IsoFileRead(isofile, teststr);
while (imagedata[newtype].name != NULL)
{
while(imagedata[newtype].name != NULL) {
if ((isofile->blocksize == imagedata[newtype].blocksize) && if ((isofile->blocksize == imagedata[newtype].blocksize) &&
(isofile->imageheader == imagedata[newtype].fileoffset))
(isofile->imageheader == imagedata[newtype].fileoffset)) { {
dataoffset = imagedata[newtype].dataoffset + 1; dataoffset = imagedata[newtype].dataoffset + 1;
i = 0; i = 0;
while ((i < 5) && (teststr[dataoffset + i] == comparestr[i])) i++; while ((i < 5) && (teststr[dataoffset + i] == comparestr[i])) i++;
if (i == 5)
if(i == 5) { {
GetImageType(isofile, newtype); GetImageType(isofile, newtype);
return(newtype); return(newtype);
} // ENDIF- Did we find a match? } // ENDIF- Did we find a match?
} // ENDIF- Do these pieces match the compression storage pieces? } // ENDIF- Do these pieces match the compression storage pieces?
newtype++; newtype++;
} // ENDWHILE- looking for the image type that fits the stats } // ENDWHILE- looking for the image type that fits the stats
}
else
{
} else { while (imagedata[newtype].name != NULL)
{
while(imagedata[newtype].name != NULL) {
targetpos = (16 * imagedata[newtype].blocksize) targetpos = (16 * imagedata[newtype].blocksize)
+ imagedata[newtype].fileoffset + imagedata[newtype].fileoffset
+ imagedata[newtype].dataoffset + imagedata[newtype].dataoffset
+ 1; // Moves to start of string + 1; // Moves to start of string
retval = ActualFileSeek(isofile->handle, targetpos); retval = ActualFileSeek(isofile->handle, targetpos);
if (retval == 0)
if(retval == 0) { {
retval = ActualFileRead(isofile->handle, 5, teststr); retval = ActualFileRead(isofile->handle, 5, teststr);
if (retval == 5)
if(retval == 5) { {
i = 0; i = 0;
while ((i < 5) && (teststr[i] == comparestr[i])) i++; while ((i < 5) && (teststr[i] == comparestr[i])) i++;
if (i == 5)
if(i == 5) { {
ActualFileSeek(isofile->handle, isofile->imageheader); ActualFileSeek(isofile->handle, isofile->imageheader);
GetImageType(isofile, newtype); GetImageType(isofile, newtype);
return(newtype); return(newtype);
} // ENDIF- Did we find a match? } // ENDIF- Did we find a match?
} // ENDIF- Could we read in the test string? Cool! Test it. } // ENDIF- Could we read in the test string? Cool! Test it.
} // ENDIF- Could actually get to this point? } // ENDIF- Could actually get to this point?
newtype++; newtype++;
} // ENDWHILE- looking for the directory header string "CD001" } // ENDWHILE- looking for the directory header string "CD001"
ActualFileSeek(isofile->handle, isofile->imageheader); ActualFileSeek(isofile->handle, isofile->imageheader);
} // ENDIF- Do we match type to compression stats? (Or search against raw data?) } // ENDIF- Do we match type to compression stats? (Or search against raw data?)
GetImageType(isofile, REDBOOK2352); GetImageType(isofile, REDBOOK2352);
return(REDBOOK2352); // Couldn't find it? Guess it's RAW 2352, then. (Audio CD?) return(REDBOOK2352); // Couldn't find it? Guess it's RAW 2352, then. (Audio CD?)
} // END ImageDetect() } // END ImageDetect()

View File

@ -1,112 +1,51 @@
/* imagetype.h /* imagetype.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef IMAGETYPE_H #ifndef IMAGETYPE_H
#define IMAGETYPE_H #define IMAGETYPE_H
// #ifndef __LINUX__ // #ifndef __LINUX__
// #ifdef __linux__ // #ifdef __linux__
// #define __LINUX__ // #define __LINUX__
// #endif /* __linux__ */ // #endif /* __linux__ */
// #endif /* No __LINUX__ */ // #endif /* No __LINUX__ */
// #define CDVDdefs // #define CDVDdefs
// #include "PS2Edefs.h" // #include "PS2Edefs.h"
#include "isofile.h" #include "isofile.h"
struct ImageTypes
{
struct ImageTypes {
char *name; char *name;
off64_t blocksize; off64_t blocksize;
off64_t fileoffset; off64_t fileoffset;
int dataoffset; int dataoffset;
int conversiontype; // For conversionbox to write a new file as. int conversiontype; // For conversionbox to write a new file as.
}; };
// Note: Worked around since a failure occurred with MSVCRT.DLL. It couldn't // Note: Worked around since a failure occurred with MSVCRT.DLL. It couldn't
// printf a char string inside an array of structures. Don't know why. // printf a char string inside an array of structures. Don't know why.
// extern struct ImageTypes imagedata[]; // extern struct ImageTypes imagedata[];
extern void GetImageType(struct IsoFile *isofile, int imagetype); extern void GetImageType(struct IsoFile *isofile, int imagetype);
extern int GetImageTypeConvertTo(int imagetype); extern int GetImageTypeConvertTo(int imagetype);
extern int DetectImageType(struct IsoFile *isofile); extern int DetectImageType(struct IsoFile *isofile);
#endif /* IMAGETYPE_H */ #endif /* IMAGETYPE_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,128 +1,64 @@
/* ini.h /* ini.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef INI_H #ifndef INI_H
#define INI_H #define INI_H
// #ifndef __LINUX__ // #ifndef __LINUX__
// #ifdef __linux__ // #ifdef __linux__
// #define __LINUX__ // #define __LINUX__
// #endif /* __linux__ */ // #endif /* __linux__ */
// #endif /* No __LINUX__ */ // #endif /* No __LINUX__ */
// #define CDVDdefs // #define CDVDdefs
// #include "PS2Edefs.h" // #include "PS2Edefs.h"
// File format: // File format:
// [section] // [section]
// keyword=value // keyword=value
// file - Name of the INI file // file - Name of the INI file
// section - Section within the file // section - Section within the file
// keyword - Identifier for a value // keyword - Identifier for a value
// value - value to store with a keyword in a section in the file // value - value to store with a keyword in a section in the file
// buffer - place to retrieve the value of a keyword // buffer - place to retrieve the value of a keyword
// return values: 0 = success, -1 = failure // return values: 0 = success, -1 = failure
// #define VERBOSE_FUNCTION_INI // #define VERBOSE_FUNCTION_INI
#define INIMAXLEN 255 #define INIMAXLEN 255
extern int INISaveString(char *file, char *section, char *keyword, char *value); extern int INISaveString(char *file, char *section, char *keyword, char *value);
extern int INILoadString(char *file, char *section, char *keyword, char *buffer); extern int INILoadString(char *file, char *section, char *keyword, char *buffer);
extern int INISaveUInt(char *file, char *section, char *keyword, unsigned int value); extern int INISaveUInt(char *file, char *section, char *keyword, unsigned int value);
extern int INILoadUInt(char *file, char *section, char *keyword, unsigned int *buffer); extern int INILoadUInt(char *file, char *section, char *keyword, unsigned int *buffer);
// NULL in the keyword below removes the whole section. // NULL in the keyword below removes the whole section.
extern int INIRemove(char *file, char *section, char *keyword); extern int INIRemove(char *file, char *section, char *keyword);
#endif /* INI_H */ #endif /* INI_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,158 +1,70 @@
/* isocompress.h /* isocompress.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef ISOCOMPRESS_H #ifndef ISOCOMPRESS_H
#define ISOCOMPRESS_H #define ISOCOMPRESS_H
#include <sys/types.h> #include <sys/types.h>
#include "isofile.h" #include "isofile.h"
#include "actualfile.h" #include "actualfile.h"
// #define VERBOSE_FUNCTION_ISOCOMPRESS // #define VERBOSE_FUNCTION_ISOCOMPRESS
// #define VERBOSE_WARNING_ISOCOMPRESS // #define VERBOSE_WARNING_ISOCOMPRESS
struct CompressExt
{
struct CompressExt {
const char *name; const char *name;
int method; int method;
}; };
#ifdef _WIN32 #ifdef _WIN32
#pragma pack(1) #pragma pack(1)
#endif /* _WIN32 */ #endif /* _WIN32 */
struct TableData
{
struct TableData {
off64_t offset; off64_t offset;
unsigned short size; unsigned short size;
#ifdef _WIN32 #ifdef _WIN32
}; };
#else #else
} __attribute__((packed)); } __attribute__((packed));
#endif /* _WIN32 */ #endif /* _WIN32 */
union TableMap
{
union TableMap {
struct TableData table; struct TableData table;
char ch[sizeof(struct TableData)]; char ch[sizeof(struct TableData)];
}; };
extern const char *compressnames[]; extern const char *compressnames[];
extern const char *compressdesc[]; extern const char *compressdesc[];
extern struct CompressExt compressext[]; extern struct CompressExt compressext[];
extern int IsoNameStripCompress(struct IsoFile *isofile); extern int IsoNameStripCompress(struct IsoFile *isofile);
// 0 = success, -1 = Failure w/data, -2 = Failure w/table // 0 = success, -1 = Failure w/data, -2 = Failure w/table
extern int CompressOpenForRead(struct IsoFile *isofile); extern int CompressOpenForRead(struct IsoFile *isofile);
extern int CompressSeek(struct IsoFile *isofile, off64_t sector); extern int CompressSeek(struct IsoFile *isofile, off64_t sector);
extern int CompressRead(struct IsoFile *isofile, char *buffer); extern int CompressRead(struct IsoFile *isofile, char *buffer);
extern void CompressClose(struct IsoFile *isofile); extern void CompressClose(struct IsoFile *isofile);
extern int CompressOpenForWrite(struct IsoFile *isofile); extern int CompressOpenForWrite(struct IsoFile *isofile);
extern int CompressWrite(struct IsoFile *isofile, char *buffer); extern int CompressWrite(struct IsoFile *isofile, char *buffer);
#endif /* ISOCOMPRESS_H */ #endif /* ISOCOMPRESS_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,246 +1,108 @@
/* isofile.h /* isofile.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef ISOFILE_H #ifndef ISOFILE_H
#define ISOFILE_H #define ISOFILE_H
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
#include "actualfile.h" #include "actualfile.h"
// #define VERBOSE_FUNCTION_ISOFILE // #define VERBOSE_FUNCTION_ISOFILE
#define VERBOSE_DISC_INFO #define VERBOSE_DISC_INFO
struct IsoFile
{
struct IsoFile {
// *** Primary Data area // *** Primary Data area
char name[256]; char name[256];
int namepos; // Used for detection of components within name int namepos; // Used for detection of components within name
ACTUALHANDLE handle; ACTUALHANDLE handle;
off64_t sectorpos; // Overall. off64_t sectorpos; // Overall.
// blocks (char [2352]) provided by users // blocks (char [2352]) provided by users
// *** Derived Stats from Primary Data // *** Derived Stats from Primary Data
int openforread; // 1 = Yes, 0 = No int openforread; // 1 = Yes, 0 = No
off64_t filebytesize; off64_t filebytesize;
off64_t filebytepos; off64_t filebytepos;
off64_t filesectorsize; off64_t filesectorsize;
off64_t filesectorpos; off64_t filesectorpos;
int cdvdtype; // for GetDiskType call int cdvdtype; // for GetDiskType call
char toc[2048]; // for GetTOC call char toc[2048]; // for GetTOC call
// From imagetype.h // From imagetype.h
int imagetype; int imagetype;
char imagename[40]; char imagename[40];
off64_t imageheader; // Header bytes in every file... off64_t imageheader; // Header bytes in every file...
off64_t blocksize; // sized to add quickly to other off64_t counters off64_t blocksize; // sized to add quickly to other off64_t counters
int blockoffset; // Where to place data in block int blockoffset; // Where to place data in block
// from isocompress.h // from isocompress.h
int compress; // Compression Method used (0 = none, 1...) int compress; // Compression Method used (0 = none, 1...)
int compresspos; // Start pos of ".Z", ".BZ", etc... int compresspos; // Start pos of ".Z", ".BZ", etc...
char tablename[256]; char tablename[256];
ACTUALHANDLE tablehandle; ACTUALHANDLE tablehandle;
char compblock[65536]; // Temporary storage of uncompressed sectors. char compblock[65536]; // Temporary storage of uncompressed sectors.
off64_t compsector; // First sector of the compblock[] off64_t compsector; // First sector of the compblock[]
off64_t numsectors; // Number of sectors in a compression block off64_t numsectors; // Number of sectors in a compression block
char *tabledata; // Table holding area char *tabledata; // Table holding area
// From multifile.h // From multifile.h
int multi; // 0 = Single File, 1 = Multiple Files int multi; // 0 = Single File, 1 = Multiple Files
int multipos; // Position of Multi # ('0'-'9') int multipos; // Position of Multi # ('0'-'9')
off64_t multisectorend[10]; // Ending sector of each file... off64_t multisectorend[10]; // Ending sector of each file...
off64_t multioffset; // To help with seek calls. Sector offset. off64_t multioffset; // To help with seek calls. Sector offset.
int multistart; // Starting file number (0-1) int multistart; // Starting file number (0-1)
int multiend; // Ending file number (?-9) int multiend; // Ending file number (?-9)
int multinow; // Current open file number int multinow; // Current open file number
// *** (Specific) Compression Data area // *** (Specific) Compression Data area
}; };
// Read-only section // Read-only section
// IsoFiles opened for read are treated as random-access files // IsoFiles opened for read are treated as random-access files
extern int IsIsoFile(const char *filename); extern int IsIsoFile(const char *filename);
// Returns an image type (positive or zero) or an error (negative) // Returns an image type (positive or zero) or an error (negative)
extern struct IsoFile *IsoFileOpenForRead(const char *filename); extern struct IsoFile *IsoFileOpenForRead(const char *filename);
// Will seek blocksize and compression method on it's own. // Will seek blocksize and compression method on it's own.
extern int IsoFileSeek(struct IsoFile *file, off64_t sector); extern int IsoFileSeek(struct IsoFile *file, off64_t sector);
// Sector, not byte. // Sector, not byte.
extern int IsoFileRead(struct IsoFile *file, char *block); extern int IsoFileRead(struct IsoFile *file, char *block);
// Buffers should be at least of "blocksize" size. 2352 bytes, please. // Buffers should be at least of "blocksize" size. 2352 bytes, please.
// Write-only section // Write-only section
// IsoFiles opened for write are treated as sequential files (still written // IsoFiles opened for write are treated as sequential files (still written
// out a block at a time, though, to be read in later as random-access) // out a block at a time, though, to be read in later as random-access)
// No plans are made to make writes random-access at this time. // No plans are made to make writes random-access at this time.
extern struct IsoFile *IsoFileOpenForWrite(const char *filename, extern struct IsoFile *IsoFileOpenForWrite(const char *filename,
int imagetype, int imagetype,
int multi, int multi,
int compress); int compress);
extern int IsoFileWrite(struct IsoFile *file, char *block); extern int IsoFileWrite(struct IsoFile *file, char *block);
// Uncompressed buffers, please. // Uncompressed buffers, please.
// Will compress with this call (if it's necessary.) // Will compress with this call (if it's necessary.)
// Calls used for all Isofiles // Calls used for all Isofiles
extern struct IsoFile *IsoFileClose(struct IsoFile *file); extern struct IsoFile *IsoFileClose(struct IsoFile *file);
// Use return variable to NULL the file pointer. // Use return variable to NULL the file pointer.
// Ex: lastfile = IsoFileClose(lastfile); // Ex: lastfile = IsoFileClose(lastfile);
extern struct IsoFile *IsoFileCloseAndDelete(struct IsoFile *file); extern struct IsoFile *IsoFileCloseAndDelete(struct IsoFile *file);
// For failure to finish writing out a file(set). // For failure to finish writing out a file(set).
#endif /* ISOFILE_H */ #endif /* ISOFILE_H */

View File

@ -1,578 +1,325 @@
/* multifile.c /* multifile.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
// #ifndef __LINUX__ // #ifndef __LINUX__
// #ifdef __linux__ // #ifdef __linux__
// #define __LINUX__ // #define __LINUX__
// #endif /* __linux__ */ // #endif /* __linux__ */
// #endif /* No __LINUX__ */ // #endif /* No __LINUX__ */
// #define CDVDdefs // #define CDVDdefs
// #include "PS2Edefs.h" // #include "PS2Edefs.h"
#include "logfile.h" #include "logfile.h"
#include "isofile.h" #include "isofile.h"
#include "isocompress.h" #include "isocompress.h"
#include "actualfile.h" #include "actualfile.h"
#include "multifile.h" #include "multifile.h"
#define FILESIZELIMIT 2000000000 #define FILESIZELIMIT 2000000000
char *multinames[] =
{
char *multinames[] = {
"", "",
"Multiple ", "Multiple ",
NULL
};
NULL }; void IsoNameStripMulti(struct IsoFile *isofile)
{
void IsoNameStripMulti(struct IsoFile *isofile) {
isofile->multi = 0; isofile->multi = 0;
if (isofile->namepos < 2) return; // Not enough digits if (isofile->namepos < 2) return; // Not enough digits
if (isofile->name[isofile->namepos - 1] < '0') return; // Ex: -I0[0] if (isofile->name[isofile->namepos - 1] < '0') return; // Ex: -I0[0]
if (isofile->name[isofile->namepos - 1] > '1') return; // Ex: -I0[1] if (isofile->name[isofile->namepos - 1] > '1') return; // Ex: -I0[1]
if (isofile->name[isofile->namepos - 2] != '0') return; // Ex: -I[0]0 if (isofile->name[isofile->namepos - 2] != '0') return; // Ex: -I[0]0
isofile->multi = 1; isofile->multi = 1;
isofile->multipos = isofile->namepos - 1; isofile->multipos = isofile->namepos - 1;
isofile->namepos -= 2; isofile->namepos -= 2;
isofile->multistart = isofile->name[isofile->multipos] - '0'; isofile->multistart = isofile->name[isofile->multipos] - '0';
isofile->multiend = isofile->multistart; isofile->multiend = isofile->multistart;
isofile->multinow = isofile->multistart; isofile->multinow = isofile->multistart;
isofile->multisectorend[0] = 0; // Sometimes the file name starts with '1' isofile->multisectorend[0] = 0; // Sometimes the file name starts with '1'
isofile->multisectorend[isofile->multistart] = isofile->filesectorsize; isofile->multisectorend[isofile->multistart] = isofile->filesectorsize;
isofile->multioffset = 0; isofile->multioffset = 0;
if (isofile->namepos < 1) return; if (isofile->namepos < 1) return;
if (isofile->name[isofile->namepos - 1] != 'I') return; // Ex: -[I]00 if (isofile->name[isofile->namepos - 1] != 'I') return; // Ex: -[I]00
isofile->namepos--; isofile->namepos--;
if (isofile->namepos < 2) return; // Filename doesn't start with '-' if (isofile->namepos < 2) return; // Filename doesn't start with '-'
if (isofile->name[isofile->namepos - 1] != '-') return; // Ex: [-]I00 if (isofile->name[isofile->namepos - 1] != '-') return; // Ex: [-]I00
isofile->namepos--; isofile->namepos--;
return; return;
} // END IsoNameStripMulti() } // END IsoNameStripMulti()
int MultiFileSeek(struct IsoFile *isofile, off64_t sector)
{
int MultiFileSeek(struct IsoFile *isofile, off64_t sector) {
int multinext; int multinext;
int retval; int retval;
off64_t tempfilesector; off64_t tempfilesector;
#ifdef VERBOSE_FUNCTION_MULTIFILE #ifdef VERBOSE_FUNCTION_MULTIFILE
PrintLog("CDVD multifile: MultiFileSeek(%llu)", sector); PrintLog("CDVD multifile: MultiFileSeek(%llu)", sector);
#endif /* VERBOSE_FUNCTION_MULTIFILE */ #endif /* VERBOSE_FUNCTION_MULTIFILE */
multinext = isofile->multinow; multinext = isofile->multinow;
// Do we need to back up a file or so? // Do we need to back up a file or so?
while ((multinext > isofile->multistart) && while ((multinext > isofile->multistart) &&
(sector < isofile->multisectorend[multinext - 1])) multinext--; (sector < isofile->multisectorend[multinext - 1])) multinext--;
// Do we need to go forward a file or two (that we know about?) // Do we need to go forward a file or two (that we know about?)
while ((multinext < isofile->multiend) && while ((multinext < isofile->multiend) &&
(sector >= isofile->multisectorend[multinext])) multinext++; (sector >= isofile->multisectorend[multinext])) multinext++;
// Do we need to go forward a file or two (that we *don't* know about?) // Do we need to go forward a file or two (that we *don't* know about?)
while ((multinext < 9) && while ((multinext < 9) &&
(sector >= isofile->multisectorend[multinext]))
(sector >= isofile->multisectorend[multinext])) { {
if (isofile->compress > 0)
if(isofile->compress > 0) { {
CompressClose(isofile); CompressClose(isofile);
}
} else { else
{
ActualFileClose(isofile->handle); ActualFileClose(isofile->handle);
isofile->handle = ACTUALHANDLENULL; isofile->handle = ACTUALHANDLENULL;
} // ENDIF- Close a compressed file? (or an uncompressed one?) } // ENDIF- Close a compressed file? (or an uncompressed one?)
multinext++; multinext++;
isofile->name[isofile->multipos] = '0' + multinext; isofile->name[isofile->multipos] = '0' + multinext;
if (isofile->compress > 0)
if(isofile->compress > 0) { {
retval = CompressOpenForRead(isofile); retval = CompressOpenForRead(isofile);
}
else
} else { {
isofile->handle = ActualFileOpenForRead(isofile->name); isofile->handle = ActualFileOpenForRead(isofile->name);
retval = 0; retval = 0;
if (isofile->handle == ACTUALHANDLENULL)
if(isofile->handle == ACTUALHANDLENULL) { {
retval = -1; retval = -1;
}
else
} else { {
isofile->filebytesize = ActualFileSize(isofile->handle); isofile->filebytesize = ActualFileSize(isofile->handle);
isofile->filesectorsize = isofile->filebytesize / isofile->blocksize; isofile->filesectorsize = isofile->filebytesize / isofile->blocksize;
isofile->filebytepos = 0; isofile->filebytepos = 0;
isofile->filesectorpos = 0; isofile->filesectorpos = 0;
} // ENDIF- Failed to open the file raw? } // ENDIF- Failed to open the file raw?
} // ENDIF- Compressed or non-compressed? What a question. } // ENDIF- Compressed or non-compressed? What a question.
if (retval < 0)
{
if(retval < 0) { if (isofile->compress > 0)
{
if(isofile->compress > 0) {
CompressClose(isofile); CompressClose(isofile);
}
} else { else
{
ActualFileClose(isofile->handle); ActualFileClose(isofile->handle);
isofile->handle = ACTUALHANDLENULL; isofile->handle = ACTUALHANDLENULL;
} // ENDIF- Close a compressed file? (or an uncompressed one?) } // ENDIF- Close a compressed file? (or an uncompressed one?)
multinext--; multinext--;
isofile->name[isofile->multipos] = '0' + multinext; isofile->name[isofile->multipos] = '0' + multinext;
if (isofile->compress > 0)
if(isofile->compress > 0) { {
CompressOpenForRead(isofile); CompressOpenForRead(isofile);
}
} else { else
{
isofile->handle = ActualFileOpenForRead(isofile->name); isofile->handle = ActualFileOpenForRead(isofile->name);
isofile->filebytesize = ActualFileSize(isofile->handle); isofile->filebytesize = ActualFileSize(isofile->handle);
isofile->filesectorsize = isofile->filebytesize / isofile->blocksize; isofile->filesectorsize = isofile->filebytesize / isofile->blocksize;
isofile->filebytepos = 0; isofile->filebytepos = 0;
isofile->filesectorpos = 0; isofile->filesectorpos = 0;
} // ENDIF- Compressed or non-compressed? What a question. } // ENDIF- Compressed or non-compressed? What a question.
isofile->multinow = multinext; isofile->multinow = multinext;
if (isofile->multinow == 0)
if(isofile->multinow == 0) { {
isofile->multioffset = 0; isofile->multioffset = 0;
}
} else { else
{
isofile->multioffset = isofile->multisectorend[isofile->multinow - 1]; isofile->multioffset = isofile->multisectorend[isofile->multinow - 1];
} // ENDIF- At the start of the list? Offset 0. } // ENDIF- At the start of the list? Offset 0.
return(-1); return(-1);
} // ENDIF- Failed to open next in series? Revert and abort. } // ENDIF- Failed to open next in series? Revert and abort.
isofile->multinow = multinext; isofile->multinow = multinext;
isofile->multiend = multinext; isofile->multiend = multinext;
isofile->multioffset = isofile->multisectorend[multinext - 1]; isofile->multioffset = isofile->multisectorend[multinext - 1];
isofile->multisectorend[multinext] = isofile->multisectorend[multinext - 1] isofile->multisectorend[multinext] = isofile->multisectorend[multinext - 1]
+ isofile->filesectorsize; + isofile->filesectorsize;
#ifdef VERBOSE_DISC_INFO #ifdef VERBOSE_DISC_INFO
PrintLog("CDVD multifile: File %i opened, %llu sectors found (%llu sectors total)", PrintLog("CDVD multifile: File %i opened, %llu sectors found (%llu sectors total)",
multinext, multinext,
isofile->filesectorsize, isofile->filesectorsize,
isofile->multisectorend[multinext]); isofile->multisectorend[multinext]);
#endif /* VERBOSE_DISC_INFO */ #endif /* VERBOSE_DISC_INFO */
} // ENDWHILE- searching through new files for a high enough end-mark } // ENDWHILE- searching through new files for a high enough end-mark
if (multinext != isofile->multinow)
{
if(multinext != isofile->multinow) {
#ifdef VERBOSE_WARNING_MULTIFILE #ifdef VERBOSE_WARNING_MULTIFILE
PrintLog("CDVD multifile: Changing to File %i", multinext); PrintLog("CDVD multifile: Changing to File %i", multinext);
#endif /* VERBOSE_WARNING_MULTIFILE */ #endif /* VERBOSE_WARNING_MULTIFILE */
if (isofile->compress > 0)
if(isofile->compress > 0) { {
CompressClose(isofile); CompressClose(isofile);
}
} else { else
{
ActualFileClose(isofile->handle); ActualFileClose(isofile->handle);
isofile->handle = ACTUALHANDLENULL; isofile->handle = ACTUALHANDLENULL;
} // ENDIF- Close a compressed file? (or an uncompressed one?) } // ENDIF- Close a compressed file? (or an uncompressed one?)
isofile->name[isofile->multipos] = '0' + multinext; isofile->name[isofile->multipos] = '0' + multinext;
if (isofile->compress > 0)
if(isofile->compress > 0) { {
CompressOpenForRead(isofile); CompressOpenForRead(isofile);
}
} else { else
{
isofile->handle = ActualFileOpenForRead(isofile->name); isofile->handle = ActualFileOpenForRead(isofile->name);
if (isofile->handle == ACTUALHANDLENULL) return(-1); // Couldn't re-open? if (isofile->handle == ACTUALHANDLENULL) return(-1); // Couldn't re-open?
isofile->filebytesize = ActualFileSize(isofile->handle); isofile->filebytesize = ActualFileSize(isofile->handle);
isofile->filesectorsize = isofile->filebytesize / isofile->blocksize; isofile->filesectorsize = isofile->filebytesize / isofile->blocksize;
isofile->filebytepos = 0; isofile->filebytepos = 0;
isofile->filesectorpos = 0; isofile->filesectorpos = 0;
} // ENDIF- Compressed or non-compressed? What a question. } // ENDIF- Compressed or non-compressed? What a question.
isofile->multinow = multinext; isofile->multinow = multinext;
if (multinext == 0)
if(multinext == 0) { {
isofile->multioffset = 0; isofile->multioffset = 0;
}
} else { else
{
isofile->multioffset = isofile->multisectorend[multinext - 1]; isofile->multioffset = isofile->multisectorend[multinext - 1];
} // ENDIF- At the start of the list? Offset 0. } // ENDIF- At the start of the list? Offset 0.
} // ENDIF- Not looking at the same file? Change to the new one. } // ENDIF- Not looking at the same file? Change to the new one.
tempfilesector = sector - isofile->multioffset; tempfilesector = sector - isofile->multioffset;
if (isofile->compress > 0)
if(isofile->compress > 0) { {
return(CompressSeek(isofile, tempfilesector)); return(CompressSeek(isofile, tempfilesector));
}
} else { else
{
retval = ActualFileSeek(isofile->handle, retval = ActualFileSeek(isofile->handle,
(tempfilesector * isofile->blocksize) (tempfilesector * isofile->blocksize)
+ isofile->imageheader); + isofile->imageheader);
if (retval == 0)
if(retval == 0) { {
isofile->filesectorpos = sector; isofile->filesectorpos = sector;
isofile->filebytepos = (sector * isofile->blocksize) isofile->filebytepos = (sector * isofile->blocksize)
+ isofile->imageheader; + isofile->imageheader;
} // ENDIF- Sucessful? Adjust internals } // ENDIF- Sucessful? Adjust internals
return(retval); return(retval);
} // ENDIF- Seek a position in a compressed file? } // ENDIF- Seek a position in a compressed file?
} // END MultiFileSeek() } // END MultiFileSeek()
int MultiFileRead(struct IsoFile *isofile, char *block)
{
int MultiFileRead(struct IsoFile *isofile, char *block) {
int retval; int retval;
#ifdef VERBOSE_FUNCTION_MULTIFILE #ifdef VERBOSE_FUNCTION_MULTIFILE
PrintLog("CDVD multifile: MultiFileRead()"); PrintLog("CDVD multifile: MultiFileRead()");
#endif /* VERBOSE_FUNCTION_MULTIFILE */ #endif /* VERBOSE_FUNCTION_MULTIFILE */
if (isofile->filesectorpos >= isofile->filesectorsize) if (isofile->filesectorpos >= isofile->filesectorsize)
MultiFileSeek(isofile, isofile->sectorpos); MultiFileSeek(isofile, isofile->sectorpos);
if (isofile->compress > 0)
{
if(isofile->compress > 0) {
return(CompressRead(isofile, block)); return(CompressRead(isofile, block));
}
} else { else
{
retval = ActualFileRead(isofile->handle, isofile->blocksize, block); retval = ActualFileRead(isofile->handle, isofile->blocksize, block);
if (retval > 0) isofile->filebytepos += retval; if (retval > 0) isofile->filebytepos += retval;
if (retval == isofile->blocksize) isofile->filesectorpos++; if (retval == isofile->blocksize) isofile->filesectorpos++;
return(retval); return(retval);
} // ENDIF- Read a compressed sector? } // ENDIF- Read a compressed sector?
} // END MultiFileRead() } // END MultiFileRead()
int MultiFileWrite(struct IsoFile *isofile, char *block)
{
int MultiFileWrite(struct IsoFile *isofile, char *block) {
int retval; int retval;
#ifdef VERBOSE_FUNCTION_MULTIFILE #ifdef VERBOSE_FUNCTION_MULTIFILE
PrintLog("CDVD multifile: MultiFileWrite()"); PrintLog("CDVD multifile: MultiFileWrite()");
#endif /* VERBOSE_FUNCTION_MULTIFILE */ #endif /* VERBOSE_FUNCTION_MULTIFILE */
if (isofile->filebytesize + isofile->blocksize > FILESIZELIMIT)
{
if (isofile->compress > 0)
if(isofile->filebytesize + isofile->blocksize > FILESIZELIMIT) { {
if(isofile->compress > 0) {
CompressClose(isofile); CompressClose(isofile);
}
} else { else
{
ActualFileClose(isofile->handle); ActualFileClose(isofile->handle);
isofile->handle = ACTUALHANDLENULL; isofile->handle = ACTUALHANDLENULL;
} // ENDIF- Close a compressed file? (or an uncompressed one?) } // ENDIF- Close a compressed file? (or an uncompressed one?)
if (isofile->multinow == 9) return(-1); // Over 10 files? Overflow! if (isofile->multinow == 9) return(-1); // Over 10 files? Overflow!
isofile->multioffset += isofile->filesectorsize; isofile->multioffset += isofile->filesectorsize;
isofile->multinow++; isofile->multinow++;
isofile->multiend++; isofile->multiend++;
#ifdef VERBOSE_WARNING_MULTIFILE #ifdef VERBOSE_WARNING_MULTIFILE
PrintLog("CDVD multifile: Changing to File %i", isofile->multinow); PrintLog("CDVD multifile: Changing to File %i", isofile->multinow);
#endif /* VERBOSE_WARNING_MULTIFILE */ #endif /* VERBOSE_WARNING_MULTIFILE */
isofile->name[isofile->multipos] = '0' + isofile->multinow; isofile->name[isofile->multipos] = '0' + isofile->multinow;
if (isofile->compress > 0)
if(isofile->compress > 0) { {
retval = CompressOpenForWrite(isofile); retval = CompressOpenForWrite(isofile);
}
} else { else
{
isofile->handle = ActualFileOpenForWrite(isofile->name); isofile->handle = ActualFileOpenForWrite(isofile->name);
if (isofile->handle == ACTUALHANDLENULL)
if(isofile->handle == ACTUALHANDLENULL) { {
retval = -1; retval = -1;
}
} else { else
{
retval = 0; retval = 0;
isofile->filebytesize = 0; isofile->filebytesize = 0;
isofile->filesectorsize = 0; isofile->filesectorsize = 0;
isofile->filebytepos = 0; isofile->filebytepos = 0;
isofile->filesectorpos = 0; isofile->filesectorpos = 0;
} // ENDIF- Trouble opening next file? } // ENDIF- Trouble opening next file?
} // ENDIF- Opening the next compressed file? (Or uncompressed?) } // ENDIF- Opening the next compressed file? (Or uncompressed?)
if (retval < 0) return(-1); // Couldn't open another file? Abort. if (retval < 0) return(-1); // Couldn't open another file? Abort.
} // ENDIF- Hit the size limit? Move on to next file... } // ENDIF- Hit the size limit? Move on to next file...
if (isofile->compress > 0)
{
if(isofile->compress > 0) {
return(CompressWrite(isofile, block)); return(CompressWrite(isofile, block));
}
} else { else
{
retval = ActualFileWrite(isofile->handle, isofile->blocksize, block); retval = ActualFileWrite(isofile->handle, isofile->blocksize, block);
if (retval > 0) isofile->filebytepos += retval; if (retval > 0) isofile->filebytepos += retval;
if (retval == isofile->blocksize) isofile->filesectorpos++; if (retval == isofile->blocksize) isofile->filesectorpos++;
return(retval); return(retval);
} // ENDIF- Write a compressed sector? } // ENDIF- Write a compressed sector?
} // END MultiFileWrite() } // END MultiFileWrite()

View File

@ -1,106 +1,45 @@
/* multifile.h /* multifile.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef MULTIFILE_H #ifndef MULTIFILE_H
#define MULTIFILE_H #define MULTIFILE_H
// #ifndef __LINUX__ // #ifndef __LINUX__
// #ifdef __linux__ // #ifdef __linux__
// #define __LINUX__ // #define __LINUX__
// #endif /* __linux__ */ // #endif /* __linux__ */
// #endif /* No __LINUX__ */ // #endif /* No __LINUX__ */
// #define CDVDdefs // #define CDVDdefs
// #include "PS2Edefs.h" // #include "PS2Edefs.h"
#include "isofile.h" #include "isofile.h"
// #define VERBOSE_FUNCTION_MULTIFILE // #define VERBOSE_FUNCTION_MULTIFILE
// #define VERBOSE_WARNING_MULTIFILE // #define VERBOSE_WARNING_MULTIFILE
extern char *multinames[]; extern char *multinames[];
extern void IsoNameStripMulti(struct IsoFile *isofile); extern void IsoNameStripMulti(struct IsoFile *isofile);
extern int MultiFileSeek(struct IsoFile *isofile, off64_t sector); extern int MultiFileSeek(struct IsoFile *isofile, off64_t sector);
extern int MultiFileRead(struct IsoFile *isofile, char *block); extern int MultiFileRead(struct IsoFile *isofile, char *block);
extern int MultiFileWrite(struct IsoFile *isofile, char *block); extern int MultiFileWrite(struct IsoFile *isofile, char *block);
#endif /* MULTIFILE_H */ #endif /* MULTIFILE_H */

View File

@ -17,35 +17,27 @@
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
#ifndef __LINUX__ #ifndef __LINUX__
#ifdef __linux__ #ifdef __linux__
#define __LINUX__ #define __LINUX__
#endif /* __linux__ */ #endif /* __linux__ */
#endif /* No __LINUX__ */ #endif /* No __LINUX__ */
#define CDVDdefs #define CDVDdefs
#include "PS2Edefs.h" #include "PS2Edefs.h"
#include "logfile.h" #include "logfile.h"
#include "convert.h" #include "convert.h"
#include "isofile.h" #include "isofile.h"
#include "actualfile.h" #include "actualfile.h"
#include "toc.h" #include "toc.h"
// PCSX2's .toc file format: // PCSX2's .toc file format:
// 1 unsigned char - CDVD_TYPE_???? // 1 unsigned char - CDVD_TYPE_????
// 1 tocTN // 1 tocTN
// As many tocTDs as it takes. // As many tocTDs as it takes.
extern void IsoInitTOC(struct IsoFile *isofile)
extern void IsoInitTOC(struct IsoFile *isofile) { {
int i; int i;
off64_t sectorsize; off64_t sectorsize;
@ -55,31 +47,36 @@ extern void IsoInitTOC(struct IsoFile *isofile) {
PrintLog("CDVDiso TOC: IsoInitTOC()"); PrintLog("CDVDiso TOC: IsoInitTOC()");
#endif /* VERBOSE_FUNCTION_TOC */ #endif /* VERBOSE_FUNCTION_TOC */
if(isofile->multi > 0) { if (isofile->multi > 0)
{
sectorsize = isofile->multisectorend[isofile->multiend]; sectorsize = isofile->multisectorend[isofile->multiend];
} else { }
else
{
sectorsize = isofile->filesectorsize; sectorsize = isofile->filesectorsize;
} // ENDIF- Establish largest sector from multifile? (or single file?) } // ENDIF- Establish largest sector from multifile? (or single file?)
for (i = 0; i < 2048; i++) isofile->toc[i] = 0; for (i = 0; i < 2048; i++) isofile->toc[i] = 0;
switch(isofile->cdvdtype) { switch (isofile->cdvdtype)
{
case CDVD_TYPE_DVDV: case CDVD_TYPE_DVDV:
case CDVD_TYPE_PS2DVD: case CDVD_TYPE_PS2DVD:
if ((isofile->filesectorsize > (2048*1024)) || if ((isofile->filesectorsize > (2048*1024)) ||
(isofile->multi > 0)) { (isofile->multi > 0))
{
isofile->toc[0] = 0x24; // Dual-Sided DVD (?) isofile->toc[0] = 0x24; // Dual-Sided DVD (?)
isofile->toc[4] = 0x41; isofile->toc[4] = 0x41;
isofile->toc[5] = 0x95; isofile->toc[5] = 0x95;
} else { }
else
{
isofile->toc[0] = 0x04; // Single-Sided DVD (?) isofile->toc[0] = 0x04; // Single-Sided DVD (?)
isofile->toc[4] = 0x86; isofile->toc[4] = 0x86;
isofile->toc[5] = 0x72; isofile->toc[5] = 0x72;
} // ENDIF- Too many sectors for a single-layered disc? } // ENDIF- Too many sectors for a single-layered disc?
isofile->toc[1] = 0x02; isofile->toc[1] = 0x02;
isofile->toc[2] = 0xF2; isofile->toc[2] = 0xF2;
isofile->toc[3] = 0x00; isofile->toc[3] = 0x00;
isofile->toc[16] = 0x00; isofile->toc[16] = 0x00;
isofile->toc[17] = 0x03; isofile->toc[17] = 0x03;
isofile->toc[18] = 0x00; isofile->toc[18] = 0x00;
@ -97,19 +94,16 @@ extern void IsoInitTOC(struct IsoFile *isofile) {
default: default:
break; break;
} // ENDSWITCH isofile->cdvdtype - Which TOC for which type? } // ENDSWITCH isofile->cdvdtype - Which TOC for which type?
// CD Details here... (tracks and stuff) // CD Details here... (tracks and stuff)
isofile->toc[2] = 0xA0; isofile->toc[2] = 0xA0;
isofile->toc[7] = 0x01; // Starting Track No. isofile->toc[7] = 0x01; // Starting Track No.
isofile->toc[12] = 0xA1; isofile->toc[12] = 0xA1;
isofile->toc[17] = 0x01; // Ending Track No. isofile->toc[17] = 0x01; // Ending Track No.
isofile->toc[22] = 0xA2; isofile->toc[22] = 0xA2;
LBAtoMSF(sectorsize, &isofile->toc[27]); LBAtoMSF(sectorsize, &isofile->toc[27]);
isofile->toc[27] = HEXTOBCD(isofile->toc[27]); isofile->toc[27] = HEXTOBCD(isofile->toc[27]);
isofile->toc[28] = HEXTOBCD(isofile->toc[28]); isofile->toc[28] = HEXTOBCD(isofile->toc[28]);
isofile->toc[29] = HEXTOBCD(isofile->toc[29]); isofile->toc[29] = HEXTOBCD(isofile->toc[29]);
isofile->toc[40] = 0x02; // YellowBook? Data Mode? isofile->toc[40] = 0x02; // YellowBook? Data Mode?
isofile->toc[42] = 0x01; // Track No. isofile->toc[42] = 0x01; // Track No.
LBAtoMSF(0, &isofile->toc[47]); LBAtoMSF(0, &isofile->toc[47]);
@ -118,43 +112,39 @@ extern void IsoInitTOC(struct IsoFile *isofile) {
isofile->toc[49] = HEXTOBCD(isofile->toc[49]); isofile->toc[49] = HEXTOBCD(isofile->toc[49]);
} // END IsoInitTOC() } // END IsoInitTOC()
extern void IsoAddTNToTOC(struct IsoFile *isofile, struct tocTN toctn)
extern void IsoAddTNToTOC(struct IsoFile *isofile, struct tocTN toctn) { {
if (isofile == NULL) return; if (isofile == NULL) return;
#ifdef VERBOSE_FUNCTION_TOC #ifdef VERBOSE_FUNCTION_TOC
PrintLog("CDVDiso TOC: IsoAddTNToTOC()"); PrintLog("CDVDiso TOC: IsoAddTNToTOC()");
#endif /* VERBOSE_FUNCTION_TOC */ #endif /* VERBOSE_FUNCTION_TOC */
isofile->toc[7] = HEXTOBCD(toctn.strack); isofile->toc[7] = HEXTOBCD(toctn.strack);
isofile->toc[17] = HEXTOBCD(toctn.etrack); isofile->toc[17] = HEXTOBCD(toctn.etrack);
return; return;
} // END IsoAddTNToTOC() } // END IsoAddTNToTOC()
extern void IsoAddTDToTOC(struct IsoFile *isofile, extern void IsoAddTDToTOC(struct IsoFile *isofile,
unsigned char track, unsigned char track,
struct tocTD toctd) { struct tocTD toctd)
{
int temptrack; int temptrack;
int position; int position;
#ifdef VERBOSE_FUNCTION_TOC #ifdef VERBOSE_FUNCTION_TOC
PrintLog("CDVDiso TOC: IsoAddTNToTOC(%u)", track); PrintLog("CDVDiso TOC: IsoAddTNToTOC(%u)", track);
#endif /* VERBOSE_FUNCTION_TOC */ #endif /* VERBOSE_FUNCTION_TOC */
if (isofile == NULL) return; if (isofile == NULL) return;
temptrack = track; temptrack = track;
if (temptrack == 0xAA) temptrack = 0; if (temptrack == 0xAA) temptrack = 0;
if (temptrack > 99) return; // Only up to 99 tracks allowed. if (temptrack > 99) return; // Only up to 99 tracks allowed.
if (temptrack == 0)
if(temptrack == 0) { {
LBAtoMSF(toctd.lsn, &isofile->toc[27]); LBAtoMSF(toctd.lsn, &isofile->toc[27]);
isofile->toc[27] = HEXTOBCD(isofile->toc[27]); isofile->toc[27] = HEXTOBCD(isofile->toc[27]);
isofile->toc[28] = HEXTOBCD(isofile->toc[28]); isofile->toc[28] = HEXTOBCD(isofile->toc[28]);
isofile->toc[29] = HEXTOBCD(isofile->toc[29]); isofile->toc[29] = HEXTOBCD(isofile->toc[29]);
}
} else { else
{
position = temptrack * 10; position = temptrack * 10;
position += 30; position += 30;
isofile->toc[position] = toctd.type; isofile->toc[position] = toctd.type;
@ -165,9 +155,8 @@ extern void IsoAddTDToTOC(struct IsoFile *isofile,
isofile->toc[position + 9] = HEXTOBCD(isofile->toc[position + 9]); isofile->toc[position + 9] = HEXTOBCD(isofile->toc[position + 9]);
} // ENDIF- Is this a lead-out? (or an actual track?) } // ENDIF- Is this a lead-out? (or an actual track?)
} // END IsoAddTDToTOC() } // END IsoAddTDToTOC()
extern int IsoLoadTOC(struct IsoFile *isofile)
{
extern int IsoLoadTOC(struct IsoFile *isofile) {
char tocext[] = ".toc\0"; char tocext[] = ".toc\0";
char tocheader[5]; char tocheader[5];
ACTUALHANDLE tochandle; ACTUALHANDLE tochandle;
@ -178,64 +167,65 @@ extern int IsoLoadTOC(struct IsoFile *isofile) {
unsigned char cdvdtype; unsigned char cdvdtype;
struct tocTN toctn; struct tocTN toctn;
struct tocTD toctd; struct tocTD toctd;
if (isofile == NULL) return(-1); if (isofile == NULL) return(-1);
i = 0; i = 0;
while((i < 256) && (isofile->name[i] != 0)) { while ((i < 256) && (isofile->name[i] != 0))
{
tocname[i] = isofile->name[i]; tocname[i] = isofile->name[i];
i++; i++;
} // ENDWHILE- Copying the data name to the toc name } // ENDWHILE- Copying the data name to the toc name
j = 0; j = 0;
while((i < 256) && (tocext[j] != 0)) { while ((i < 256) && (tocext[j] != 0))
{
tocname[i] = tocext[j]; tocname[i] = tocext[j];
i++; i++;
j++; j++;
} // ENDWHILE- Append ".toc" to end of name } // ENDWHILE- Append ".toc" to end of name
tocname[i] = 0; // And 0-terminate tocname[i] = 0; // And 0-terminate
tochandle = ActualFileOpenForRead(tocname); tochandle = ActualFileOpenForRead(tocname);
if (tochandle == ACTUALHANDLENULL) return(-1); if (tochandle == ACTUALHANDLENULL) return(-1);
retval = ActualFileRead(tochandle, 4, tocheader); retval = ActualFileRead(tochandle, 4, tocheader);
if(retval < 4) { if (retval < 4)
{
ActualFileClose(tochandle); ActualFileClose(tochandle);
tochandle = ACTUALHANDLENULL; tochandle = ACTUALHANDLENULL;
return(-1); return(-1);
} // ENDIF- Trouble reading the 'toc' file? } // ENDIF- Trouble reading the 'toc' file?
if ((tocheader[0] != 'T') || if ((tocheader[0] != 'T') ||
(tocheader[1] != 'O') || (tocheader[1] != 'O') ||
(tocheader[2] != 'C') || (tocheader[2] != 'C') ||
(tocheader[3] != '1')) { (tocheader[3] != '1'))
{
ActualFileClose(tochandle); ActualFileClose(tochandle);
tochandle = ACTUALHANDLENULL; tochandle = ACTUALHANDLENULL;
return(-1); return(-1);
} // ENDIF- Not a 'toc' file after all? } // ENDIF- Not a 'toc' file after all?
#ifdef VERBOSE_FUNCTION_TOC #ifdef VERBOSE_FUNCTION_TOC
PrintLog("CDVDiso TOC: IsoLoadTOC(%s)", tocname); PrintLog("CDVDiso TOC: IsoLoadTOC(%s)", tocname);
#endif /* VERBOSE_FUNCTION_TOC */ #endif /* VERBOSE_FUNCTION_TOC */
retval = ActualFileRead(tochandle, 1, (char *) & cdvdtype); retval = ActualFileRead(tochandle, 1, (char *) & cdvdtype);
if(retval < 1) { if (retval < 1)
{
ActualFileClose(tochandle); ActualFileClose(tochandle);
tochandle = ACTUALHANDLENULL; tochandle = ACTUALHANDLENULL;
return(-1); return(-1);
} // ENDIF- Trouble reading the 'toc' file? } // ENDIF- Trouble reading the 'toc' file?
isofile->cdvdtype = cdvdtype; isofile->cdvdtype = cdvdtype;
IsoInitTOC(isofile); IsoInitTOC(isofile);
if((cdvdtype != CDVD_TYPE_PS2DVD) && (cdvdtype != CDVD_TYPE_DVDV)) { if ((cdvdtype != CDVD_TYPE_PS2DVD) && (cdvdtype != CDVD_TYPE_DVDV))
{
retval = ActualFileRead(tochandle, sizeof(struct tocTN), (char *) & toctn); retval = ActualFileRead(tochandle, sizeof(struct tocTN), (char *) & toctn);
if(retval < sizeof(struct tocTN)) { if (retval < sizeof(struct tocTN))
{
ActualFileClose(tochandle); ActualFileClose(tochandle);
tochandle = ACTUALHANDLENULL; tochandle = ACTUALHANDLENULL;
return(-1); return(-1);
} // ENDIF- Trouble reading the 'toc' file? } // ENDIF- Trouble reading the 'toc' file?
if((toctn.strack > 99) || (toctn.etrack > 99)) { if ((toctn.strack > 99) || (toctn.etrack > 99))
{
ActualFileClose(tochandle); ActualFileClose(tochandle);
tochandle = ACTUALHANDLENULL; tochandle = ACTUALHANDLENULL;
return(-1); return(-1);
@ -245,15 +235,15 @@ extern int IsoLoadTOC(struct IsoFile *isofile) {
toctn.strack, toctn.etrack); toctn.strack, toctn.etrack);
#endif /* VERBOSE_FUNCTION_TOC */ #endif /* VERBOSE_FUNCTION_TOC */
IsoAddTNToTOC(isofile, toctn); IsoAddTNToTOC(isofile, toctn);
retval = ActualFileRead(tochandle, sizeof(struct tocTD), (char *) & toctd); retval = ActualFileRead(tochandle, sizeof(struct tocTD), (char *) & toctd);
if(retval < sizeof(struct tocTD)) { if (retval < sizeof(struct tocTD))
{
ActualFileClose(tochandle); ActualFileClose(tochandle);
tochandle = ACTUALHANDLENULL; tochandle = ACTUALHANDLENULL;
return(-1); return(-1);
} // ENDIF- Trouble reading the 'toc' file? } // ENDIF- Trouble reading the 'toc' file?
if (toctd.type != 0)
if(toctd.type != 0) { {
ActualFileClose(tochandle); ActualFileClose(tochandle);
tochandle = ACTUALHANDLENULL; tochandle = ACTUALHANDLENULL;
return(-1); return(-1);
@ -262,11 +252,11 @@ extern int IsoLoadTOC(struct IsoFile *isofile) {
PrintLog("CDVDiso TOC: Total Sectors: %lu", toctd.lsn); PrintLog("CDVDiso TOC: Total Sectors: %lu", toctd.lsn);
#endif /* VERBOSE_FUNCTION_TOC */ #endif /* VERBOSE_FUNCTION_TOC */
IsoAddTDToTOC(isofile, 0xAA, toctd); IsoAddTDToTOC(isofile, 0xAA, toctd);
for (i = toctn.strack; i <= toctn.etrack; i++)
for(i = toctn.strack; i <= toctn.etrack; i++) { {
retval = ActualFileRead(tochandle, sizeof(struct tocTD), (char *) & toctd); retval = ActualFileRead(tochandle, sizeof(struct tocTD), (char *) & toctd);
if(retval < sizeof(struct tocTD)) { if (retval < sizeof(struct tocTD))
{
ActualFileClose(tochandle); ActualFileClose(tochandle);
tochandle = ACTUALHANDLENULL; tochandle = ACTUALHANDLENULL;
return(-1); return(-1);
@ -280,12 +270,11 @@ extern int IsoLoadTOC(struct IsoFile *isofile) {
} // ENDIF- Not a DVD? (Then read in CD track data) } // ENDIF- Not a DVD? (Then read in CD track data)
ActualFileClose(tochandle); ActualFileClose(tochandle);
tochandle = ACTUALHANDLENULL; tochandle = ACTUALHANDLENULL;
return(0); return(0);
} // END IsoLoadTOC() } // END IsoLoadTOC()
extern int IsoSaveTOC(struct IsoFile *isofile)
extern int IsoSaveTOC(struct IsoFile *isofile) { {
char tocext[] = ".toc\0"; char tocext[] = ".toc\0";
char tocheader[] = "TOC1\0"; char tocheader[] = "TOC1\0";
ACTUALHANDLE tochandle; ACTUALHANDLE tochandle;
@ -297,16 +286,16 @@ extern int IsoSaveTOC(struct IsoFile *isofile) {
struct tocTN toctn; struct tocTN toctn;
struct tocTD toctd; struct tocTD toctd;
char temptime[3]; char temptime[3];
if (isofile == NULL) return(-1); if (isofile == NULL) return(-1);
i = 0; i = 0;
while((i < 256) && (isofile->name[i] != 0)) { while ((i < 256) && (isofile->name[i] != 0))
{
tocname[i] = isofile->name[i]; tocname[i] = isofile->name[i];
i++; i++;
} // ENDWHILE- Copying the data name to the toc name } // ENDWHILE- Copying the data name to the toc name
j = 0; j = 0;
while((i < 256) && (tocext[j] != 0)) { while ((i < 256) && (tocext[j] != 0))
{
tocname[i] = tocext[j]; tocname[i] = tocext[j];
i++; i++;
j++; j++;
@ -318,7 +307,8 @@ extern int IsoSaveTOC(struct IsoFile *isofile) {
if (tochandle == ACTUALHANDLENULL) return(-1); if (tochandle == ACTUALHANDLENULL) return(-1);
retval = ActualFileWrite(tochandle, 4, tocheader); retval = ActualFileWrite(tochandle, 4, tocheader);
if(retval < 4) { if (retval < 4)
{
ActualFileClose(tochandle); ActualFileClose(tochandle);
tochandle = ACTUALHANDLENULL; tochandle = ACTUALHANDLENULL;
ActualFileDelete(tocname); ActualFileDelete(tocname);
@ -327,12 +317,11 @@ extern int IsoSaveTOC(struct IsoFile *isofile) {
cdvdtype = isofile->cdvdtype; cdvdtype = isofile->cdvdtype;
ActualFileWrite(tochandle, 1, (char *) &cdvdtype); ActualFileWrite(tochandle, 1, (char *) &cdvdtype);
if ((cdvdtype != CDVD_TYPE_PS2DVD) && (cdvdtype != CDVD_TYPE_DVDV))
if((cdvdtype != CDVD_TYPE_PS2DVD) && (cdvdtype != CDVD_TYPE_DVDV)) { {
toctn.strack = BCDTOHEX(isofile->toc[7]); toctn.strack = BCDTOHEX(isofile->toc[7]);
toctn.etrack = BCDTOHEX(isofile->toc[17]); toctn.etrack = BCDTOHEX(isofile->toc[17]);
ActualFileWrite(tochandle, sizeof(struct tocTN), (char *) &toctn); ActualFileWrite(tochandle, sizeof(struct tocTN), (char *) &toctn);
// Leadout Data // Leadout Data
toctd.type = 0; toctd.type = 0;
temptime[0] = BCDTOHEX(isofile->toc[27]); temptime[0] = BCDTOHEX(isofile->toc[27]);
@ -340,8 +329,8 @@ extern int IsoSaveTOC(struct IsoFile *isofile) {
temptime[2] = BCDTOHEX(isofile->toc[29]); temptime[2] = BCDTOHEX(isofile->toc[29]);
toctd.lsn = MSFtoLBA(temptime); toctd.lsn = MSFtoLBA(temptime);
ActualFileWrite(tochandle, sizeof(struct tocTD), (char *) &toctd); ActualFileWrite(tochandle, sizeof(struct tocTD), (char *) &toctd);
for (i = toctn.strack; i <= toctn.etrack; i++)
for(i = toctn.strack; i <= toctn.etrack; i++) { {
j = i * 10 + 30; j = i * 10 + 30;
toctd.type = isofile->toc[j]; toctd.type = isofile->toc[j];
temptime[0] = BCDTOHEX(isofile->toc[j + 7]); temptime[0] = BCDTOHEX(isofile->toc[j + 7]);
@ -353,6 +342,5 @@ extern int IsoSaveTOC(struct IsoFile *isofile) {
} // ENDIF- Not a DVD? (Then output CD track data) } // ENDIF- Not a DVD? (Then output CD track data)
ActualFileClose(tochandle); ActualFileClose(tochandle);
tochandle = ACTUALHANDLENULL; tochandle = ACTUALHANDLENULL;
return(0); return(0);
} // END IsoSaveTOC() } // END IsoSaveTOC()

View File

@ -17,12 +17,9 @@
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef TOC_H #ifndef TOC_H
#define TOC_H #define TOC_H
// #ifndef __LINUX__ // #ifndef __LINUX__
// #ifdef __linux__ // #ifdef __linux__
// #define __LINUX__ // #define __LINUX__
@ -31,18 +28,15 @@
// #define CDVDdefs // #define CDVDdefs
// #include "PS2Edefs.h" // #include "PS2Edefs.h"
#include "isofile.h" #include "isofile.h"
// #define VERBOSE_FUNCTION_TOC // #define VERBOSE_FUNCTION_TOC
#ifdef _WIN32 #ifdef _WIN32
#pragma pack(1) #pragma pack(1)
#endif /* _WIN32 */ #endif /* _WIN32 */
struct tocTD
struct tocTD { {
unsigned long lsn; unsigned long lsn;
unsigned char type; unsigned char type;
#ifdef _WIN32 #ifdef _WIN32
@ -51,7 +45,8 @@ struct tocTD {
} __attribute__((packed)); } __attribute__((packed));
#endif /* _WIN32 */ #endif /* _WIN32 */
struct tocTN { struct tocTN
{
unsigned char strack; unsigned char strack;
unsigned char etrack; unsigned char etrack;
#ifdef _WIN32 #ifdef _WIN32
@ -59,26 +54,20 @@ struct tocTN {
#else #else
} __attribute__((packed)); } __attribute__((packed));
#endif /* _WIN32 */ #endif /* _WIN32 */
#ifdef _WIN32 #ifdef _WIN32
#pragma pack() #pragma pack()
#endif /* _WIN32 */ #endif /* _WIN32 */
// PCSX2's .toc file format: // PCSX2's .toc file format:
// 1 unsigned char - CDVD_TYPE_???? // 1 unsigned char - CDVD_TYPE_????
// 1 tocTN // 1 tocTN
// As many tocTDs as it takes. // As many tocTDs as it takes.
extern void IsoInitTOC(struct IsoFile *isofile); extern void IsoInitTOC(struct IsoFile *isofile);
extern void IsoAddTNToTOC(struct IsoFile *isofile, struct tocTN toctn); extern void IsoAddTNToTOC(struct IsoFile *isofile, struct tocTN toctn);
extern void IsoAddTDToTOC(struct IsoFile *isofile, extern void IsoAddTDToTOC(struct IsoFile *isofile,
unsigned char track, unsigned char track,
struct tocTD toctd); struct tocTD toctd);
extern int IsoLoadTOC(struct IsoFile *isofile); extern int IsoLoadTOC(struct IsoFile *isofile);
extern int IsoSaveTOC(struct IsoFile *isofile); extern int IsoSaveTOC(struct IsoFile *isofile);
#endif /* TOC_H */ #endif /* TOC_H */

View File

@ -1,72 +1,36 @@
/* version.c /* version.c
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef __LINUX__ #ifndef __LINUX__
#ifdef __linux__ #ifdef __linux__
#define __LINUX__ #define __LINUX__
#endif /* __linux__ */ #endif /* __linux__ */
#endif /* No __LINUX__ */ #endif /* No __LINUX__ */
#define CDVDdefs #define CDVDdefs
#include "PS2Edefs.h" #include "PS2Edefs.h"
char *libname = "EFP Iso CDVD Driver"; char *libname = "EFP Iso CDVD Driver";
const unsigned char version = PS2E_CDVD_VERSION; const unsigned char version = PS2E_CDVD_VERSION;
const unsigned char revision = 0; const unsigned char revision = 0;
const unsigned char build = 6; const unsigned char build = 6;

View File

@ -1,86 +1,39 @@
/* version.h /* version.h
* Copyright (C) 2002-2005 PCSX2 Team * Copyright (C) 2002-2005 PCSX2 Team
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* PCSX2 members can be contacted through their website at www.pcsx2.net. * PCSX2 members can be contacted through their website at www.pcsx2.net.
*/ */
#ifndef VERSION_H #ifndef VERSION_H
#define VERSION_H #define VERSION_H
#ifndef __LINUX__ #ifndef __LINUX__
#ifdef __linux__ #ifdef __linux__
#define __LINUX__ #define __LINUX__
#endif /* __linux__ */ #endif /* __linux__ */
#endif /* No __LINUX__ */ #endif /* No __LINUX__ */
#define CDVDdefs #define CDVDdefs
#include "PS2Edefs.h" #include "PS2Edefs.h"
extern char *libname; extern char *libname;
extern const unsigned char version; extern const unsigned char version;
extern const unsigned char revision; extern const unsigned char revision;
extern const unsigned char build; extern const unsigned char build;
#endif /* VERSION_H */ #endif /* VERSION_H */